Java写一个简单的英雄数据

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;
    }
}
  • 11
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值