Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- string[] productNames = new string[100];
- int[] productQuantities = new int[100];
- int productCount = 0;
- while (true)
- {
- Console.WriteLine("1. Покажи всички продукти");
- Console.WriteLine("2. Създай нов продукт");
- Console.WriteLine("3. Редактирай продукт");
- Console.Write("Изберете опция: ");
- string choice = Console.ReadLine();
- if (choice == "1")
- {
- for (int i = 0; i < productCount; i++)
- {
- Console.WriteLine($"{i + 1}. {productNames[i]} - {productQuantities[i]} бр.");
- }
- }
- else if (choice == "2")
- {
- Console.Write("Въведете име на продукта: ");
- string name = Console.ReadLine();
- Console.Write("Въведете количество: ");
- int quantity = int.Parse(Console.ReadLine());
- productNames[productCount] = name;
- productQuantities[productCount] = quantity;
- productCount++;
- }
- else if (choice == "3")
- {
- Console.Write("Въведете номер на продукта за редакция: ");
- int index = int.Parse(Console.ReadLine()) - 1;
- if (index >= 0 && index < productCount)
- {
- Console.Write("Ново име на продукта: ");
- productNames[index] = Console.ReadLine();
- Console.Write("Ново количество: ");
- productQuantities[index] = int.Parse(Console.ReadLine());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement