public Storage() { Product konsola = new ProductElectronics(1, "konsola PS4", 1000, "sony"); Product marchewka = new ProductFood(2, "marchewka", 2.5); Product spodnie = new ProductClothes(3, "buty", 120, "42"); Product jeansy = new ProductClothes(4, "spodnie", 220, "XL"); Product dresy = new ProductClothes(5, "kurtka", 350, "M"); storageList.Add(konsola); storageList.Add(marchewka); storageList.Add(spodnie); storageList.Add(jeansy); storageList.Add(dresy); }
/// <summary> /// Dodaje produkt do magazynu /// </summary> public void AddToStorage() { Console.Clear(); Product product; Console.WriteLine("Wybierz kategorię \n" + "1. Elektronika. \n" + "2. Żywność. \n" + "3. Ubrania. \n" + "4. Powrót. \n"); button = Console.ReadKey(true).KeyChar; val = (int)button - 48; switch (val) { //elektronika case 1: Console.Clear(); Console.WriteLine("Podaj ID produktu:"); int id = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj nazwę produktu:"); string name = Console.ReadLine(); Console.WriteLine("Podaj cenę produktu:"); double price = double.Parse(Console.ReadLine()); Console.WriteLine("Podaj markę produktu:"); string brand = Console.ReadLine(); product = new ProductElectronics(id, name, price, brand); storage.AddProduct(product); break; //żywność case 2: Console.Clear(); Console.WriteLine("Podaj ID produktu:"); id = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj nazwę produktu:"); name = Console.ReadLine(); Console.WriteLine("Podaj cenę produktu:"); price = double.Parse(Console.ReadLine()); product = new ProductFood(id, name, price); storage.AddProduct(product); break; //ubrania case 3: Console.Clear(); Console.Clear(); Console.WriteLine("Podaj ID produktu:"); id = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj nazwę produktu:"); name = Console.ReadLine(); Console.WriteLine("Podaj cenę produktu:"); price = double.Parse(Console.ReadLine()); Console.WriteLine("Podaj rozmiar produktu:"); string size = Console.ReadLine(); product = new ProductClothes(id, name, price, size); storage.AddProduct(product); break; //powrót case 4: Console.Clear(); ChooseAction(); break; } }