第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

破壞統(tǒng)一性的構(gòu)造函數(shù)

破壞統(tǒng)一性的構(gòu)造函數(shù)

C#
楊__羊羊 2021-04-30 15:09:56
編碼Army.Add(new PigSquad("The Old Guard", 10, 4));哪里Army是List<Unit>和Pigsquad被定義為public class PigSquad : Unit{    public override bool Dead { get; set; }    public override string Name { get; set;}    public override int Strength { get; set; }    public override int Age { get { return Age; } set { Age = value; Strength += 20 - Age; if (Age > 20) { Dead = true; } } }    public override int Veterancy { get; set; }    public PigSquad()    {    }    public PigSquad(string Name)    {        this.Name = Name;    }    public PigSquad(string Name, int Strength)    {        this.Name = Name;        this.Strength = Strength;    }    public PigSquad(string Name, int Strength, int Age)    {        this.Name = Name;        this.Strength = Strength;        this.Age = Age;    }}運(yùn)行時(shí)使Unity編輯器崩潰。我不知道為什么會(huì)這樣。在這方面的任何幫助將不勝感激。
查看完整描述

1 回答

?
九州編程

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊

public override int Age { get { return Age; } set { Age = value; Strength += 20 - Age; if (Age > 20) { Dead = true; } } }

應(yīng)該

private int _Age; //maybe make this in your UNIT object as well and that way you do not need it in your child.
public override int Age { get { return _Age; } set { _Age = value; Strength += 20 - _Age; if (Age > 20) { Dead = true; } } }



查看完整回答
反對(duì) 回復(fù) 2021-05-08
  • 1 回答
  • 0 關(guān)注
  • 151 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)