本帖最后由 王海平 于 2016-4-20 09:46 编辑
class Demo_Cf {
public static void main(String[] args) {
Cf h1 = new Cf();
h1.setWuqi("黑龙");
h1.setJiaqian(888);
System.out.println(h1.getWuqi()+".."+h1.getJiaqian());
h1.hurt();
h1.pingjia();
Cf h2 = new Cf();
h2.setWuqi("麒麟");
h2.setJiaqian(888);
System.out.println(h2.getWuqi()+".."+h2.getJiaqian());
h2.hurt();
h2.pingjia();
Cf h3 = new Cf();
h3.setWuqi("无影");
h3.setJiaqian(888);
System.out.println(h3.getWuqi()+".."+h3.getJiaqian());
h3.hurt();
h3.pingjia();
Cf h4 = new Cf();
h4.setWuqi("黑骑士");
h4.setJiaqian(888);
System.out.println(h4.getWuqi()+".."+h4.getJiaqian());
h4.hurt();
h4.pingjia();
Cf h5 = new Cf();
h5.setWuqi("雷神");
h5.setJiaqian(888);
System.out.println(h5.getWuqi()+".."+h5.getJiaqian());
h5.hurt();
h5.pingjia();
}
}
class Cf {
private String wuqi;
private int jiaqian;
public void setWuqi(String wuqi){
this.wuqi = wuqi;
//System.out.println(wuqi);
}
public String getWuqi(){
return wuqi;
}
public void setJiaqian(int jiaqian){
this.jiaqian = jiaqian;
//System.out.println(jiaqian);
}
public int getJiaqian(){
return jiaqian;
}
public void hurt(){
if (wuqi=="黑龙") {
System.out.println("一枪不爆头");
}else if(wuqi=="麒麟") {
System.out.println("一枪爆头");
}
else if(wuqi=="无影") {
System.out.println("一枪爆头");
}
else if(wuqi=="黑骑士") {
System.out.println("一枪不爆头");
}
else if(wuqi=="雷神") {
System.out.println("一枪不爆头");
}
}
public void pingjia(){
if (wuqi=="黑龙") {
System.out.println("弹道平稳,我喜欢用,太贵");
}else if(wuqi=="麒麟") {
System.out.println("弹道平稳,不过没什么卵用");
}
else if(wuqi=="无影") {
System.out.println("弹道平稳,我喜欢用,不过买不起");
}
else if(wuqi=="黑骑士") {
System.out.println("一般,不适合扫射");
}
else if(wuqi=="雷神") {
System.out.println("点射爆头,好用");
}
}
}
——————————————————————————————————————
class Demo_Dnf {
public static void main(String[] args) {
Dnf role1 = new Dnf();
role1.setZhiye("冰结师");
role1.setJibie(86);
System.out.println("role1是" + role1.getJibie()+"级的"+role1.getZhiye());
role1.hurt();
role1.control();
Dnf role2 = new Dnf();
role2.setZhiye("驱魔师");
role2.setJibie(86);
System.out.println("role2是" + role2.getJibie()+"级的"+role2.getZhiye());
role2.hurt();
role2.control();
Dnf role3 = new Dnf();
role3.setZhiye("阿修罗");
role3.setJibie(86);
System.out.println("role3是" + role3.getJibie()+"级的"+role3.getZhiye());
role3.hurt();
role3.control();
Dnf role4 = new Dnf();
role4.setZhiye("剑魂");
role4.setJibie(86);
System.out.println("role4是" + role4.getJibie()+"级的"+role4.getZhiye());
role4.hurt();
role4.control();
Dnf role5 = new Dnf();
role5.setZhiye("奶爸");
role5.setJibie(86);
System.out.println("role5是" + role5.getJibie()+"级的"+role5.getZhiye());
role5.hurt();
role5.control();
}
}
class Dnf {
private String zhiye;
private int jibie;
public void setZhiye(String zhiye) {
this.zhiye = zhiye;
//System.out.println(zhiye);
}
public String getZhiye() {
return this.zhiye;
}
public int setJibie(int jibie) {
this.jibie = jibie;
//System.out.println(jibie);
return jibie;
}
public int getJibie() {
return this.jibie;
}
public void hurt() {
if (zhiye == "冰结师") {
System.out.println("伤害很高");
}else if (zhiye == "驱魔师") {
System.out.println("伤害爆表");
}else if (zhiye == "阿修罗") {
System.out.println("伤害逆天");
}else if (zhiye == "剑魂") {
System.out.println("他就是个垃圾");
}else {
System.out.println("神,不解释了");
}
}
public void control() {
if (zhiye == "冰结师") {
System.out.println("冰结师有点控制");
}else if (zhiye == "驱魔师") {
System.out.println("只有一条狗");
}else if (zhiye == "阿修罗") {
System.out.println("安图恩可以辅助");
}else if (zhiye == "剑魂") {
System.out.println("呵呵呵");
}else {
System.out.println("依旧是神,不解释了");
}
}
}
|
|