我的作业请指点。
package com.imooc;
public abstract class Human {//父类
public abstract void speak();
}
package com.imooc;
public class Chinese extends Human {
@Override
public void speak() {
// TODO Auto-generated method stub
System.out.println("中国人说中国话");
}
}
package com.imooc;
public class American extends Human {
@Override
public void speak( ) {
// TODO Auto-generated method stub
System.out.println("美国人说英语");
}
}
package com.imooc;
import java.util.Scanner;
public class Test3 {
public static void main(String[] args) {
Human h1=new Chinese();
Human h2=new American();
Scanner s=new Scanner(System.in);
System.out.println("请输入不同国家的人(如Chinese)");
if(s.nextLine().equals("Chinese")) {
h1.speak();
}
if(s.nextLine().equals("American")) {
h2.speak();
}
}
}