博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Java]利用面向对象知识来完成“游戏代练场景”
阅读量:3941 次
发布时间:2019-05-24

本文共 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/

你可能感兴趣的文章
3.7.4 - Indexing and Slicing Strings
查看>>
3.7.5 - Modifying Strings
查看>>
3.7.6 - String Methods
查看>>
3.8 - Using the Print Function
查看>>
3.9.1 - Lists in Python
查看>>
3.9.2 - Lists - Adding and Removing Objects
查看>>
3.9.3 - Sorting Lists
查看>>
3.10 - Maya Commands: ls
查看>>
3.11 - Dictionaries in Python
查看>>
3.12 - Tuples in Python
查看>>
4.4 - For Loops
查看>>
4.2.2 - Logical and/or Operators
查看>>
Lesson 4 Part 2 Softmax Regression
查看>>
文章中运用到的数学公式
查看>>
Projective Dynamics: Fusing Constraint Projections for Fast Simulation
查看>>
从2D恢复出3D的数据
查看>>
glm 中 数据类型 与 原始数据(c++ 数组)之间的转换
查看>>
Derivatives of scalars, vector functions and matrices
查看>>
the jacobian matrix and the gradient matrix
查看>>
VS2010 将背景设为保护色
查看>>