就像這樣的
這種的設計模式,先寫什麼後寫什麼,
求大神幫我羅列書詳細步驟圖,我是個新手,
所以比較蒙,感謝各位大神了,或者有類似的代碼也可以。
------------十分感謝你們的幫助
public abstract class Home
{
public string description = "空房子";
public abstract string getDescription();
public Double Area;
public abstract Double getArea();
}
//房子
public class House : Home
{
public House()
{
description = "MyHouse:";
}
public override string getDescription()
{
return description;
}
public override Double getArea()
{
return 0.0;
}
}
//主臥
public class MainCell : Home
{
Home home;
public MainCell(Home home,Double area)
{
this.home = home;
this.Area = area;
}
public override string getDescription()
{
return this.home.getDescription() + " MainCell";
}
public override Double getArea()
{
return this.Area + home.getArea();
}
}
//陽台
public class Balcony : Home
{
Home home;
public Balcony(Home home, Double area)
{
this.home = home;
this.Area = area;
}
public override string getDescription()
{
return this.home.getDescription() + " Balcony";
}
public override Double getArea()
{
return this.Area + home.getArea();
}
}