示例#1
0
文件: driver.cs 项目: Vsio/Virulife
    static void Main(string[] args)
    {
        Console.Write("\n\n###### Program starts ######\n\n");

        Rhombus rhombus = new Rhombus();
        string newChar;
        int newMaxWidth;

        header();

        Console.Write("\nInput a Character value => ");
        newChar = Console.ReadLine();

        Console.Write("\nInput the Rhombus's maximum width value => ");
        newMaxWidth = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n\n");

        rhombus.setChar(newChar[0]);
        rhombus.setMaxWidth(newMaxWidth);

        rhombus.drawRhombus();

        Console.Write("\n\n###### Program ends ######\n\n");

        Console.ReadLine(); // Pause programs before exit
    }
示例#2
0
        static void Main(string[] args)
        {
            Circle circle = new Circle(5);
            Rhombus rhombus = new Rhombus(5, 2);
            Rectangle rectangle = new Rectangle(2, 10);

            IShape[] shapes = { circle,rhombus,rectangle};

            foreach (var shape in shapes)
            {
                Console.WriteLine("Area: {0}",shape.CalculateArea());
                Console.WriteLine("Perimeter: {0}", shape.CalculatePerimeter());
            }
        }
示例#3
0
    public static void Main()
    {
        Rectangle rectangle = new Rectangle(4, 6);
        Rhombus rhombus = new Rhombus(2, 5);
        Circle circle = new Circle(12);

        Console.WriteLine("Rectangle:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n",
            rectangle.CalculateArea(),
            rectangle.CalculatePerimeter()
            );
        Console.WriteLine("Rhombus:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n",
            rhombus.CalculateArea(),
            rhombus.CalculatePerimeter()
            );
        Console.WriteLine("Circle:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n",
            circle.CalculateArea(),
            circle.CalculatePerimeter()
            );
    }
示例#4
0
        static void Main()
        {
            Rectangle firstRectangle = new Rectangle(4.5, 7.3);
            Circle firstCircle = new Circle(4);
            Rhombus firstRhombus = new Rhombus(5.2, 3.75);
            BasicShape secondRectangle = new Rectangle(12, 3.1);
            BasicShape secondRhombus = new Rhombus(8, 3.1);
            Circle seocndCircle = new Circle(3.5);
            IShape[] shapes =
            {
                firstRectangle,
                firstCircle,
                firstRhombus,
                secondRectangle,
                secondRhombus,
                seocndCircle
            };

            foreach (var shape in shapes)
            {
                Console.WriteLine(shape.ToString());
            }
        }