//第一题 文件1CanCry.java
public interface CanCry {
\x09public void cry();
}
//第一题 文件2 Cat.java
public class Cat implements CanCry {
\x09public void cry() {
\x09\x09System.out.println("猫,叫声是喵喵喵");
\x09}
}
//第一题 文件3 Dog.java
public class Dog implements CanCry {
\x09public void cry() {
\x09\x09System.out.println("狗,叫声是汪汪汪");
\x09}
}
//第一题 文件4 G.java
public class G {
\x09void makeCry(CanCry c){
\x09\x09c.cry();
\x09}
\x09public static void main(String[] args) {
\x09\x09Cat cat = new Cat();
\x09\x09Dog dog = new Dog();
\x09\x09G g = new G();
\x09\x09g.makeCry(cat);
\x09\x09g.makeCry(dog);
\x09}
}
//第二题 R.java
public class R {
\x09public int[] abc(int len){
\x09\x09int[] result = new int[len];
\x09\x09for(int i=0;i
\x09\x09\x09result[i] = (int)(Math.random()*(11)+10);
\x09\x09}
\x09\x09return result;
\x09}
\x09public void printA(int[] info){
\x09\x09int len = info.length;
\x09\x09for(int i=0;i
\x09\x09\x09System.out.println(info[i]);
\x09\x09}
\x09}
\x09public static void main(String[] args) {
\x09\x09R r = new R();
\x09\x09int[] info = r.abc(10);
\x09\x09r.printA(info);
\x09}
}
作业帮用户
2016-12-02
举报