2014年4月14日 星期一

[Code Review] Team 07 - Hw06 Version2

執行檔.exe

[Code Review] Team 02 - Hw06 Other 01

老師在之前的投影片有提到:父類別的參考可以用來記錄子類別的物件,但就無法使用子類別的特有屬性與方法了。

但有時候還是需要得到子類別特有的屬性或使用特有的方法時,這邊提供了一個寫法給大家參考(但可能很爛),也回應一些組別遇到的問題。這個方法建立在多型的概念上。


按我顯示程式碼

[Code Review] Team 06 - Hw06

TextBox的顯現有參考第二組的寫法. 執行檔 專案檔

2014年4月13日 星期日

[Code Review] Team 09 - Hw06

在此超有誠意的附上整個專案檔
https://drive.google.com/file/d/0B9vj2TjBHPutWVBablNsVU5NNTJ0MTdmd0lrQjRGQ0FlbU00/edit?usp=sharing


[Code Review] Team 10 - Hw06


[Code Review] Team 03 - Hw06

執行檔 Form1.cs 按我顯示
Shape
class Shape
    {
        protected double L1, L2;
        protected double density;
        protected double pi = 3.1415926;
        protected static int amount = 0;
        public static int Amount
        {
            get { return amount; }
        }

        public Shape(double L1, double density)
        {
            this.L1 = L1;
            this.density = density;
            amount++;
        }
        public Shape(double L1, double L2, double density)
        {
            this.L1 = L1;
            this.L2 = L2;
            this.density = density;
            amount++;
        }
        public virtual double CalVolume() { return 0; }
        public virtual string GetName() { return ""; }
        public double CalQuality() { return CalVolume() * density; }
        public string Show()
        {
            string str="";
            str += GetName()+"\t";
            str += L1 + "\t" + L2 + "\t";
            str += density + "\t";
            str += CalVolume() + "\t";
            str += CalQuality() + "\n";
            return str;
        }
    }
Ball
class Ball : Shape
    {
        
        public Ball(double L1, double density) : base(L1, density) { }
        public static Ball Create(double L1,  double density)
        {
            Ball ball = null;
            if (L1 <= 0 )
            {
                return ball;
            }
            else
            {
                ball = new Ball(L1, density);
                return ball;
            }
        }
        public override double CalVolume()
        {
            return pi * L1 * L1 * L1 * 4 / 3;
        }
        public override string GetName()
        {
            return "Ball";
        }
    }
Cube
class Cube : Shape
    {
        public Cube(double L1, double density) : base(L1, density) { }
        public static Cube Create(double L1, double density)
        {
            Cube cube = null;
            if (L1 <= 0 )
            {
                return cube;
            }
            else
            {
                cube = new Cube(L1, density);
                return cube;
            }
        }
        public override double CalVolume()
        {
            return L1 * L1 * L1 ;
        }
        public override string GetName()
        {
            return "Cube";
        }
    }
Cylinder
class Cylinder : Shape
    {
        public Cylinder(double L1, double L2, double density) : base(L1, L2, density) { }
        public static Cylinder Create(double L1, double L2, double density)
        {
            Cylinder cylinder = null;
            if (L1 <= 0 || L2 <= 0)
            {
                return cylinder;
            }
            else
            {
                cylinder = new Cylinder(L1, L2, density);
                return cylinder;
            }
        }
        public override double CalVolume()
        {
            return pi * L1 * L1 * L2;
        }
        public override string GetName()
        {
            return "Cylinder";
        }

    }
Pyramid
class Pyramid : Shape
    {
         public Pyramid(double L1, double L2, double density) : base(L1, L2, density) { }
         public static Pyramid Create(double L1, double L2, double density)
         {
             Pyramid pyramid = null;
             if (L1 <= 0 || L2 <= 0)
             {
                 return pyramid;
             }
             else
             {
                 pyramid = new Pyramid(L1, L2, density);
                 return pyramid;
             }
         }
         public override double CalVolume()
         {
             return (L1 * L1 * L2) / 3;
         }
         public override string GetName()
         {
             return "Pyramid";
         }
 

    }

[Code Review] Team 04 - Hw06

程式檔

[Code Review] Team 07 - Hw06

檔案下載



[Code Review] Team 01 - Hw06

[Code Review] Team 05 - Hw06