描述西游记中的人物

1.代码
package Demo2;

class Character{
	private String name;  //人物名字
	private String nose;  //人物鼻子
	private String mouth; //人物嘴巴
	private String eye;   //人物眼睛
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getNose() {
		return nose;
	}
	public void setNose(String nose) {
		this.nose = nose;
	}
	public String getMouth() {
		return mouth;
	}
	public void setMouth(String mouth) {
		this.mouth = mouth;
	}
	public String getEye() {
		return eye;
	}
	public void setEye(String eye) {
		this.eye = eye;
	}
	public Character() {
		super();
	}
	public Character(String name, String nose, String mouth, String eye) {
		super();
		this.name = name;
		this.nose = nose;
		this.mouth = mouth;
		this.eye = eye;
	}
	public void action(String name){
		if(name.equalsIgnoreCase("孙悟空")){
			System.out.println("孙悟空使用金箍棒大妖精");
		}else if(name.equalsIgnoreCase("猪八戒")){
			System.out.println("猪八戒使用锄头打妖精");
		}else {
			System.out.println("沙僧使用弯刀抢打妖精");
		}
	}
	public void show(){
		System.out.println(name+"外貌特征:"+nose+","+mouth+","+eye);
	}
	
}
public class Person {

	public static void main(String[] args) {
		Character c1=new Character("孙悟空", "猴子鼻", "樱桃嘴", "火眼");
		c1.show();
		c1.action("孙悟空");
		System.out.println();
		Character c2=new Character("猪八戒", "帅哥鼻", "大头嘴", "媚人眼");
		c2.show();
		c2.action("猪八戒");
		System.out.println();
		Character c3=new Character("沙僧", "君子鼻", "憨厚嘴", "沙眼");
		c3.show();
		c3.action("沙僧");

	}

}

2.截图


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值