Пример #1
0
        public void ChangeFlatAppliances(string userChoice)
        {
            bool quitChangeFlatAppliances = false;

            do
            {
                switch (userChoice)
                {
                case "1":
                    var serializer = new TextSerializer();
                    serializer.Serialize(flatAppliances);
                    quitChangeFlatAppliances = true;
                    break;

                case "2":
                    var binserializer = new BinarySerializer();
                    binserializer.Serialize(flatAppliances);
                    quitChangeFlatAppliances = true;
                    break;

                case "3":
                    SwitchOnMenu();
                    ReturnAppliances();
                    quitChangeFlatAppliances = true;
                    break;

                case "4":
                    SwitchOffMenu();
                    ReturnAppliances();
                    quitChangeFlatAppliances = true;
                    break;

                case "5":
                    SortByPower();
                    quitChangeFlatAppliances = true;
                    break;

                case "6":
                    ShowFromRange();
                    ReturnAppliances();
                    quitChangeFlatAppliances = true;
                    break;

                case "7":
                    DeleteMenu();
                    ReturnAppliances();
                    quitChangeFlatAppliances = true;
                    break;

                default:
                    Console.WriteLine("Wrong command, choose a number (1-7)");
                    userChoice = Console.ReadLine();
                    quitChangeFlatAppliances = false;
                    break;
                }
            } while (quitChangeFlatAppliances == false);
        }
Пример #2
0
        public void CreateFlatAppliances(string userChoice)
        {
            bool quitCreateFlatAppliances = false;

            do
            {
                switch (userChoice)
                {
                case "Default":
                    AddAppliance(new Televisor(1, "Sony", "HRMN-100", "Red", 1000, 42, "1280x960", "CLD"));
                    AddAppliance(new MultimediaAcousticSystem(2, "SVEN", "CDO-50", "Black", 20, 5.1));
                    AddAppliance(new Notebook(3, "ASUS", "SX50", "Black", 325, "2x2000GHr", 1000000, 8000, "GeForce NX500", "800x600", 15, true));
                    AddAppliance(new PC(4, "Pentium", "5", "Black", 550, "5x2000GHr", 1000000, 4000, "GeForce sX8000", "1920x1080", 24, false));
                    AddAppliance(new Fridge(5, "Atlant", "SX200", "White", 500, 1.9, 0.6, 0.7, true));
                    AddAppliance(new Washer(6, "LG", "L5", "Silver", 800, 1.2, 1.0, 0.45, 800, 5));
                    AddAppliance(new Ketle(7, "Bosh", "S5", "Silver", 550, 1.2));
                    AddAppliance(new VacuumCleaner(8, "Samsung", "GCRE1800", "Purple", 600, 1800));
                    ReturnAppliances();
                    quitCreateFlatAppliances = true;
                    break;

                case "TXT":
                    var serializer = new TextSerializer();
                    flatAppliances = serializer.Deserialize();
                    ReturnAppliances();
                    quitCreateFlatAppliances = true;
                    break;

                case "BIN":
                    BinarySerializer binSerializer = new BinarySerializer();
                    flatAppliances = binSerializer.Deserialize();
                    foreach (var app in flatAppliances)
                    {
                        ReturnAppliances();
                    }
                    quitCreateFlatAppliances = true;
                    break;

                default:
                    Console.WriteLine("Wrong command, choose from the following options (Default, TXT, BIN)");
                    userChoice = Console.ReadLine();
                    quitCreateFlatAppliances = false;
                    break;
                }
            } while (quitCreateFlatAppliances == false);
        }