Example #1
0
        static void Main(string[] args)
        {
            triangle A = new triangle(3, 4, 5);

            Console.WriteLine(A.isTriangle());
            Console.WriteLine(A.getMeasure());
            rectangle B = new rectangle(3, 4);

            Console.WriteLine(B.getMeasure());
            square C = new square(3);

            Console.WriteLine(C.getMeasure());
        }
Example #2
0
        public static shape createShape(string s)
        {
            shape sp = null;

            switch (s)
            {
            case "三角形":
                sp = new triangle();
                break;

            case "矩形":
                sp = new rectangle();
                break;

            case "正方形":
                sp = new square();
                break;

            default:
                throw new Exception("参数错误");
            }
            return(sp);
        }