1. 程式人生 > >某遊戲中有巫師角色,巫師的屬性有級別、戰鬥力。

某遊戲中有巫師角色,巫師的屬性有級別、戰鬥力。

某遊戲中有巫師角色,巫師的屬性有級別、戰鬥力。

// 巫師類
class Wizard
    {
        //建立物件後,巫師具有10000的生命值
        public Wizard()
        {
            LifeValue = 10000;
        }
        //建立物件時,可以給巫師指定級別、戰鬥力、生命值。
        public Wizard(string level , double combatEffectiveness,double lifeValue)
        {
            this.Level =
level; this.CombatEffectiveness = combatEffectiveness; this.LifeValue = lifeValue; } //級別 public string Level { get; set; } //戰鬥力 public double CombatEffectiveness { get; set; } //生命值 public double LifeValue { get; set; } public
void Info() { Console.WriteLine("我是巫師,我的級別{0},戰鬥力{1},生命值{2}",Level,CombatEffectiveness,LifeValue); } } //執行方法 static void Main(string[] args) { Wizard wizard1 = new Wizard(); wizard1.Info(); Wizard wizard2 = new Wizard("帝王",
999999,9999999); wizard2.Info(); Console.Read(); }