コード例 #1
0
ファイル: Program.cs プロジェクト: ryanhamilton11/MSSA_CAD
        static void Main(string[] args)
        {
            Circle c1 = new Circle(-1);

            c1.SetRadius(2.0);

            Circle c2 = new Circle();

            c2.SetRadius(3);

            Circle c3 = new Circle();

            c3.SetRadius(0);

            Rectangle r1 = new Rectangle(-1, -2);

            r1.SetLength(2.0);
            r1.SetWidth(-0.1);

            Rectangle r2 = new Rectangle();

            r2.SetLength(3);
            r2.SetLength(-2);

            Rectangle r3 = new Rectangle();

            r3.SetLength(0);
            r3.SetWidth(0);

            Square s1 = new Square(-1);

            s1.SetSide(2.0);

            Square s2 = new Square();

            s2.SetSide(3);

            Square s3 = new Square();

            s3.SetSide(0);

            Triangle t1 = new Triangle(0, 1, 2);

            t1.SetSideA(2.0);
            t1.SetSideB(0);
            t1.SetSideC(-0.2);


            Triangle t2 = new Triangle(-1, 0, 1);

            t1.SetSideA(12);
            t1.SetSideB(-0);
            t1.SetSideC(-21);

            Triangle t3 = new Triangle(-0, 0, 1);

            t1.SetSideA(0.0);
            t1.SetSideB(0.1);
            t1.SetSideC(-0.2);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Rectangle
            Rectangle rect1 = new Rectangle("Blue", 3, 5);

            Console.WriteLine("\nrect1 Area: " + rect1.GetArea());
            Console.WriteLine("rect1 Perimeter: " + rect1.GetPerimeter());
            Console.WriteLine("rect1 Length: " + rect1.GetLength());
            rect1.SetColor("Magenta");
            Console.WriteLine(rect1.GetColor());
            rect1.SetWidth(5);

            // Circle
            Circle circ1 = new Circle("Red", 4);

            Console.WriteLine("\ncirc1 Area: " + circ1.GetArea());
            Console.WriteLine("circ1 Circumference: " + circ1.GetPerimeter());
            Console.WriteLine("circ1 Radius: " + circ1.GetRadius());
            circ1.SetColor("Lime Green");
            Console.WriteLine(circ1.GetColor());
            circ1.SetRadius(8);

            // Square
            Square sqr1 = new Square("White", 2);

            Console.WriteLine("\nsqr1 Area: " + sqr1.GetArea());
            Console.WriteLine("sqr1 Perimeter: " + sqr1.GetPerimeter());
            Console.WriteLine("sqr1 Side: " + sqr1.GetSide());
            sqr1.SetColor("Cyan");
            Console.WriteLine(sqr1.GetColor());
            sqr1.SetSide(5);

            // Triangle
            Triangle tri1 = new Triangle("Black", 3, 5, 7);

            Console.WriteLine("\ntri1 Area: " + tri1.GetArea());
            Console.WriteLine("tri1 Perimeter: " + tri1.GetPerimeter());
            Console.WriteLine("tri1 SideA: " + tri1.GetSideA());
            tri1.SetColor("Lilac");
            Console.WriteLine(tri1.GetColor());
            tri1.SetSideC(5);

            // Hexagon
            Hexagon hex1 = new Hexagon(2);

            Console.WriteLine("\nhex1 Area: " + hex1.GetArea());
            Console.Write("hex1 Perimeter: " + hex1.GetPerimeter());
        }