编程1的Test1类改成这个:
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Child[] children = new Child[3];
String nameChild = sc.next();
String nameToy = sc.next();
int footbollRadius = sc.nextInt();
Toy toy1 = new Football(nameToy,footbollRadius);
children[0]= new Child(nameChild,toy1);
nameChild = sc.next();
nameToy = sc.next();
String color = sc.next();
Toy toy2 = new TeddyBear(nameToy,color);
children[1] = new Child(nameChild,toy2);
nameChild = sc.next();
nameToy = sc.next();
String shape = sc.next();
Toy toy3 = new Kite(nameToy,shape);
children[2] = new Child(nameChild,toy3);
for(Child child : children){
child.playMyToy();
}
}
}