用java语言,编写一个简单的人物游戏属性面版

本文介绍了如何在Java中定义一个名为`BasicInformation`的类,用于表示游戏角色的基本属性,包括角色名称、年龄、种族、职业等,并展示了构造函数和`displayBasicInformation`方法来显示角色详细信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package jiadianxitong;

// 定义角色的基本信息类
public class BasicInformation {
    // 私有成员变量,封装角色的属性
    private String role;          // 角色名称
    private int age;              // 角色年龄
    private Race race;            // 角色种族
    private Career career;        // 角色职业
    private int grade;            // 角色等级
    private EducationLevel education; // 角色学历
    private int power;            // 角色力量
    private int agile;            // 角色敏捷
    private int constitution;      // 角色体质
    private int intelligence;      // 角色智力
    private int perception;        // 角色感知
    private int charm;             // 角色魅力
    private String talent;         // 角色天赋
    private Skill skill;            // 角色技能
    private Equipment equip;       // 角色装备

    // 构造函数,用于初始化角色的基本信息
    public BasicInformation(String role, int age, Race race, Career career, int grade, EducationLevel education,
                           int power, int agile, int constitution, int intelligence, int perception, int charm, String talent,
                           Skill skill, Equipment equip) {
        this.role = role;
        this.age = age;
        this.race = race;
        this.career = career;
        this.grade = grade;
        this.education = education;
        this.power = power;
        this.agile = agile;
        this.constitution = constitution;
        this.intelligence = intelligence;
        this.perception = perception;
        this.charm = charm;
        this.talent = talent;
        this.skill = skill;
        this.equip = equip;
    }

 

public String displayBasicInformation() {

return "\t姓名:" + role + "\n" +

"\t年龄:" + age + "岁\n" +

"\t种族:" + race + "\n" +

"\t职业:" + career + "\n" +

"\t职业等级:" + grade + "级\n" +

"\t学历:" + education + "\n" +

"\t力量:" + power + "\n" +

"\t敏捷:" + agile + "\n" +

"\t体质:" + constitution + "\n" +

"\t智力:" + intelligence + "\n" +

"\t感知:" + perception + "\n" +

"\t魅力:" + charm + "\n" +

"\t天赋:" + talent + "\n" +

"\t技能:" + skill.toString() + "\n" +

"\t装备:" + equip.toString();

}

}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值