本文共 930 字,大约阅读时间需要 3 分钟。
package gametest;public class Game { public void star() { System.out.println("开机开机准备上线!"); } public void play() { System.out.println("开始打游戏咯。。。"); } public void end() { System.out.println("累死了,关机睡觉!"); }}
package gametest;public class DNF extends Game { public void play() { System.out.println("刷深渊中。。。"); }}
package gametest;public class LOL extends Game { public void play() { System.out.println("对线单杀,EAQAWAA..."); }}
package gametest;public class CS extends Game { public void play() { System.out.println("中门对狙中..."); }}
package gametest;public class Player { public void happy(Game game) { game.star(); game.play(); game.end(); System.out.println("拿到工资100元。。。。。。。"); }}
package gametest;public class Client { public static void main(String[] args) { Game game1 = new DNF(); Game game2 = new LOL(); Game game3 = new CS(); Player play = new Player(); play.happy(game1); play.happy(game2); play.happy(game3); }}
转载地址:http://ztnwi.baihongyu.com/