0
的ArrayList我有下面的類:更新startRobot方法,因此現在能滿足機器人
import java.util.ArrayList;
import java.util.Scanner;
public class Tester04 {
public static void main(String[] args) {
EntertainmentRobot eRob = new EntertainmentRobot("QRIO", 7.3, 0.6, "SONY");
HumanStudyRobot rob = new HumanStudyRobot("HRP", 1.5, 58.0, "Kawada Industries");
ArrayList<Robot> list = new ArrayList<Robot>();
list.add(eRob);
list.add(rob);
eRob.setPurpose("To live with you, make life fun and make you happy");
rob.setPurpose("Study into human movement and perform a wide range of tasks");
System.out.print(list.get(0) + "\n" + list.get(1));
}
public static void startRobot(Robot robot, Scanner input) {
robot.doTask(input);
robot.doTask();
}
}
正如你可以看到我已經建立了機器人的ArrayList
。我現在試圖更新我的startRobot方法來迎合這樣一個arrayList,我不確定如何繼續。任何意見,將不勝感激,謝謝!