public class Student02 {
public static void main(String[] args) {
// 创建学生对象 yx0,使用带有三个技能参数的构造函数
Student02 yx0 = new Student02("亚瑟", "战士", 200, 44, 30, 2.4, "致命打击:增加移速并第一次攻击后带1秒沉默", "回旋斩:并造成0.4倍攻击力", "圣剑裁决:瞬间造成1.3倍物理打击并附带50魔法伤害");
// 创建学生对象 yx1,使用带有四个技能参数的构造函数
Student02 yx1 = new Student02("宫本武藏", "刺客", 210, 53, 35, 1.9, "心眼被动:第四次普攻将会穿过目标,并减少二天一流的冷却时间", "无双:宫本武藏以强大剑气斩出一道龙卷风将击飞敌人", "神速:宫本武藏向前神速突进,这个技能在冷却之前可以连续释放三次", "二天一流:宫本武藏跳向敌人上方凭空出剑,对其范围敌人造成伤害并击飞眩晕1.8秒");
System.out.println(yx0.read()); // 打印 yx0 学生对象的信息
System.out.println(yx1.read()); // 打印 yx1 学生对象的信息
}
// 学生类的属性和方法
private String name; // 姓名
private String occupation; // 职业
private int strength; // 力量
private int intellect; // 智力
private int critical; // 暴击率
private double criticals; // 暴击效果
private String skill1; // 技能1
private String skill2; // 技能2
private String skill3; // 技能3
private String skill4; // 技能4
// 构造函数,用于初始化学生对象
public Student02(String name, String occupation, int strength, int intellect, int critical, double criticals, String skill1, String skill2, String skill3) {
this.name = name;
this.occupation = occupation;
this.strength = strength;
this.intellect = intellect;
this.critical = critical;
this.criticals = criticals;
this.skill1 = skill1;
this.skill2 = skill2;
this.skill3 = skill3;
}
// 构造函数,用于初始化学生对象
public Student02(String name, String occupation, int strength, int intellect, int critical, double criticals, String skill1, String skill2, String skill3, String skill4) {
this.name = name;
this.occupation = occupation;
this.strength = strength;
this.intellect = intellect;
this.critical = critical;
this.criticals = criticals;
this.skill1 = skill1;
this.skill2 = skill2;
this.skill3 = skill3;
this.skill4 = skill4;
}
// 读取学生对象的信息
public String read() {
return "名字:" + this.name + "\n职业:" + this.occupation + "\n力量:" + this.strength + "\n智力:" + this.intellect + "\n暴击率:" + this.critical + "%\n暴击效果:" + this.criticals + "\n技能1:" + this.skill1 + "\n技能2:" + this.skill2 + "\n技能3:" + this.skill3 + "\n技能4:" + this.skill4;
}
}
Java写一个简单的英雄数据
最新推荐文章于 2024-06-14 15:02:13 发布