Esempio n. 1
0
        private static void printAllData()
        {
            Console.WriteLine("DATA OF ALL ELEMENTS IN LIST");

            foreach (Shape shape in DataModel.getAllElementsList())
            {
                shape.printData();
            }
        }
Esempio n. 2
0
        private static void doSubMenuCircle()
        {
            Console.WriteLine("You are in sub menu for circle - insert the value of radius:");
            Console.Write("Radius=");
            string input;

            while (true)
            {
                input = Console.ReadLine();
                if (input.Trim() != "")
                {
                    try
                    {
                        double r        = System.Convert.ToDouble(input);
                        Circle myCircle = new Circle(r);
                        DataModel.getAllElementsList().Add(myCircle);
                        Console.WriteLine("New circle inserted!");
                        Console.Write("Do you want to insert one more circle? (y/n)");

                        string s;
                        while (true)
                        {
                            s = Console.ReadLine().Trim();
                            if (s == "y")
                            {
                                Console.Write("Radius=");
                                break;
                            }
                            else if (s == "n")
                            {
                                Console.WriteLine();
                                printMainMenu();
                                return;
                            }
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Value for radius is not correct!");
                        Console.Write("Radius=");
                    }
                }
            }
        }
Esempio n. 3
0
        private static void doSubMenuSquare()
        {
            Console.WriteLine("You are in sub menu for square - insert the value for the side of square:");
            Console.Write("Side of square=");
            string input;

            while (true)
            {
                input = Console.ReadLine();
                if (input.Trim() != "")
                {
                    try
                    {
                        double a        = System.Convert.ToDouble(input);
                        Square mySquare = new Square(a);
                        DataModel.getAllElementsList().Add(mySquare);
                        Console.WriteLine("New square inserted!");
                        Console.Write("Do you want to insert one more square? (y/n)");

                        string s;
                        while (true)
                        {
                            s = Console.ReadLine().Trim();
                            if (s == "y")
                            {
                                Console.Write("Side of square=");
                                break;
                            }
                            else if (s == "n")
                            {
                                Console.WriteLine();
                                printMainMenu();
                                return;
                            }
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Value for the side of square is not correct!");
                        Console.Write("Side of square=");
                    }
                }
            }
        }