根据以下类图来完成“游戏代练”场景
Homework6_Game:
public class Homework6_Game {
public void start() {
System.out.println("开机,准备就绪");
}
public void play() {
System.out.println("我要打游戏");
}
public void end() {
System.out.println("关机,睡觉");
}
}
Homework6_DNF:
public class Homework6_DNF extends Homework6_Game {
public void play() {
System.out.println("刷刷刷,肝就行了");
}
}
Homework6_LOL:
public class Homework6_LOL extends Homework6_Game {
public void play() {
System.out.println("上盖仑,快乐儿童劫,拜拜");
}
}
Homework6_CS:
public class Homework6_CS extends Homework6_Game {
public void play() {
System.out.println("没有八倍镜,照样团灭");
}
}
Homework6_Player
public class Homework6_Player {
public void happy(Homework6_Game game) {
game.start();
game.play();
game.end();
System.out.println("开心");
}
}
Homework6_Client:
public class Homework6_Client {
public static void main(String[] args) {
Homework6_Game game1 = new Homework6_DNF();
Homework6_Game game2 = new Homework6_LOL();
Homework6_Game game3 = new Homework6_CS();
Homework6_Player p = new Homework6_Player();
p.happy(game1);
p.happy(game2);
p.happy(game3);
}
}