Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.39 KB | None | 0 0
  1. using System;
  2. namespace ConsoleApp3
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             Product[] product = { new Product(1,"Маска трехслойная", 900, 100), new Product(2, "Аппарат ИВЛ",20000, 2), new Product(3, "Гречка", 150, 10), new Product(4, "Туалетная бумага", 200, 20) };
  9.             Player player = new Player(100000, "");
  10.             Seller seller = new Seller(0, "");
  11.             while (true)
  12.             {
  13.                 Console.WriteLine("Добро пожаловать в магазин!");
  14.  
  15.                 Console.WriteLine();
  16.                 Console.WriteLine("У Вас в кошельке есть - "+ player.Coins + " рублей.");
  17.                 Console.WriteLine();
  18.                 Console.WriteLine("/nВеедите 'товары' чтобы посмотреть ассортимет магазина./nВведите 'пакет', что бы посмотреть покупки.");
  19.                 string command = Console.ReadLine();
  20.                 switch (command)
  21.                 {
  22.                     case "1":
  23.  
  24.                         break;
  25.                     case "2":
  26.  
  27.                         break;
  28.                     case "3":
  29.  
  30.                         break;
  31.                     case "4":
  32.  
  33.                         break;
  34.                     case "пакет":
  35.                         player.MyBag();
  36.                         break;
  37.  
  38.                     case "товары":
  39.                         Console.WriteLine("У нас Вы можете купить:");
  40.                         Console.WriteLine();
  41.                         for (int i = 0; i < product.Length; i++)
  42.                         {
  43.                             product[i].ShowProduct();
  44.                         }
  45.                         Console.WriteLine();
  46.                         Console.WriteLine("Введите номер товара, который Вы хотели бы приобрести.");
  47.                         Console.WriteLine("Поторопитесь, количество товара ограничено!");
  48.                         break;
  49.                 }
  50.                 Console.ReadKey();
  51.             }
  52.         }
  53.     }
  54.     class Player
  55.     {
  56.         public int Coins;
  57.         public string[] Inventory;
  58.  
  59.         public Player(int coins, string[] inventory)
  60.         {
  61.             Coins = coins;
  62.             Inventory = inventory;
  63.         }
  64.  
  65.         public void MyBag()
  66.         {
  67.             Console.WriteLine(Inventory);
  68.         }
  69.     }
  70.     class Seller
  71.     {
  72.         public int Coins;
  73.         public string[] Inventory;
  74.  
  75.         public Seller(int coins, string[] inventory)
  76.         {
  77.             Coins = coins;
  78.             Inventory = inventory;
  79.         }
  80.     }
  81.     class Product
  82.     {
  83.         public int Number;
  84.         public string ProductName;
  85.         public int ProductCost;
  86.         public int ProductQuantity;
  87.  
  88.         public Product(int number, string productName, int productCost, int productQuantity)
  89.         {
  90.             Number = number;
  91.             ProductName = productName;
  92.             ProductCost = productCost;
  93.             ProductQuantity = productQuantity;
  94.         }
  95.  
  96.         public void ShowProduct()
  97.         {
  98.             Console.WriteLine($"{Number}. {ProductName} по цене - {ProductCost} рублей");
  99.         }
  100.  
  101.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement