Esempio n. 1
0
        public static Rhomb SetRhomb(out string name, out string type, out double a, out double h,
                                     out double area, out double perim, out int tops, out int edges)
        {
            Console.Write("Set Name of Rhomb: ");
            name = Console.ReadLine();

            Console.Write("Set Type of Rhomb: ");
            type = Console.ReadLine();

            Console.Write("Enter a side of Rhomb:\n");
            Console.Write("a: ");
            a = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
            Console.Write("Enter h:\n");
            Console.Write("h: ");
            h = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Rhomb rhomb = new Rhomb(a, h);

            rhomb.A    = a;
            rhomb.H    = h;
            rhomb.Name = name;
            rhomb.Type = type;
            area       = rhomb.Area();
            perim      = rhomb.Perimeter();
            tops       = rhomb.QuantityOfTops();
            edges      = rhomb.QuantityOfEdges();

            return(rhomb);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Write down 2 sides and angle for figures splitting them with spaces:");
            var line = Console.ReadLine();
            var vals = line.Split(' ');

            if (vals.Length != 3)
            {
                Console.WriteLine("Wrong count of arguments.");
                Console.ReadKey();
                return;
            }

            double side1   = double.Parse(vals[0]),
                   side2   = double.Parse(vals[1]),
                   angle   = double.Parse(vals[2]);
            double minSide = side1 <side2?side1 : side2,
                                    maxSide = side1> side2 ? side1 : side2;
            Figure fig;

            Console.WriteLine("Creating Parallelogram:");
            fig = new Parallelogram(minSide, maxSide, angle);
            Console.WriteLine($"Area = {fig.Area():F3}\tPerimeter = {fig.Perimeter():F3}\n");

            Console.WriteLine("Creating Rectangle:");
            fig = new Rectangle(minSide, maxSide);
            Console.WriteLine($"Area = {fig.Area():F3}\tPerimeter = {fig.Perimeter():F3}\n");

            Console.WriteLine("Creating Square:");
            fig = new Square(maxSide);
            Console.WriteLine($"Area = {fig.Area():F3}\tPerimeter = {fig.Perimeter():F3}\n");

            Console.WriteLine("Creating Rhomb:");
            fig = new Rhomb(maxSide, angle);
            Console.WriteLine($"Area = {fig.Area():F3}\tPerimeter = {fig.Perimeter():F3}\n");

            Console.ReadKey();
        }