Advertisement
Guest User

5.3

a guest
May 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.IO;
  8.  
  9. namespace Lesson5
  10. {
  11.     class Program
  12.     {
  13.        
  14.         static void Main(string[] args)
  15.         {
  16.             string[] tovar = { "Орешки", "Пиво", "Сухарики", "Сидр", "Семечки", "Чипсы" };
  17.             int[] price = { 15, 50, 15, 65, 10, 30 };
  18.             int[] ostatok = { 50, 50, 30, 60, 23, 15 };
  19.             string name = "";
  20.             int summa_zakaza = 0;
  21.             int kassa = 0;
  22.  
  23.             Menu( tovar, ostatok, price,name, summa_zakaza,kassa);
  24.  
  25.            
  26.  
  27.  
  28.         }
  29.  
  30.  
  31.  
  32.         static void Begin(string [] tovar,int [] price,string name)
  33.         {
  34.  
  35.            
  36.            
  37.             Console.WriteLine("Введите имя оператора: ");
  38.             name = Console.ReadLine();
  39.             Console.Clear();
  40.             Console.WriteLine("Теперь ты новый продавец в этой пивной!\nТак вот, " + name + ", тебе предстоит продавать:\n ");
  41.  
  42.             for (int i = 0; i < tovar.Length; i++)
  43.             {
  44.  
  45.                 string position = tovar[i];
  46.                 string stoimost = Convert.ToString(price[i]);
  47.  
  48.                 Console.WriteLine(position + " за " + stoimost + " руб.\n");
  49.  
  50.             }
  51.             Console.WriteLine();
  52.  
  53.             Console.WriteLine("Нажми любую клавишу и приступай!\nУдачи!");
  54.             Console.ReadKey();
  55.             Console.Clear();
  56.             //return name;
  57.         }
  58.  
  59.  
  60.  
  61.         static void Sklad(ref string[] tovar,ref int [] ostatok)
  62.         {
  63.             Console.Clear();
  64.             Console.WriteLine("Остатки:\n");
  65.  
  66.             for (int i = 0; i < tovar.Length; i++)
  67.             {
  68.                 string position = tovar[i];
  69.                 string Sklad_ostatok = Convert.ToString(ostatok[i]);
  70.  
  71.                 Console.Write(position + " - " + Sklad_ostatok + " Ед.\n");
  72.  
  73.             }
  74.             Console.WriteLine();
  75.             Console.WriteLine("Нажми любую клавишу для возврата в меню...");
  76.             Console.ReadKey();
  77.             Console.Clear();
  78.  
  79.  
  80.         }
  81.  
  82.  
  83.         static void Zakaz(ref string[] tovar,ref int [] price,ref int kassa , ref int summa_zakaza, ref int[] ostatok)
  84.         {
  85.             bool ves_zakaz = false;
  86.             string vibor;
  87.             string tovar_zakaz;
  88.             int num_tovar_zakaz = 0;
  89.             int x = 42, y = 2;
  90.          
  91.  
  92.  
  93.             Console.WriteLine("Создай заказ: ");
  94.            
  95.             while (!ves_zakaz)
  96.             {
  97.  
  98.                 Console.Clear();
  99.  
  100.  
  101.                 Console.SetCursorPosition(0, 0);
  102.                 Console.Write("Товар: ");
  103.                 tovar_zakaz = Console.ReadLine();
  104.  
  105.                 Console.Write("Кол-во товара в заказе: ");
  106.                 num_tovar_zakaz = Convert.ToInt32(Console.ReadLine());
  107.  
  108.                 for (int i = 0; i < tovar.Length; i++)
  109.                 {
  110.                     if (tovar[i].ToLower().StartsWith(tovar_zakaz))
  111.                     {
  112.                        
  113.                         if (num_tovar_zakaz > ostatok[i])
  114.                         {
  115.                             Console.WriteLine("Указанное кол-во превышает складской остаток\n" +
  116.                                 "Запрашиваемого товара на складе: "+ ostatok[i]);
  117.                         }
  118.                         else
  119.                         {
  120.                             ostatok[i] = ostatok[i] - num_tovar_zakaz;
  121.                             summa_zakaza += (price[i] * num_tovar_zakaz);
  122.  
  123.                         }                      
  124.                        
  125.  
  126.                     }
  127.                    
  128.  
  129.                 }
  130.  
  131.                 Console.Write("Сумма заказа - " + summa_zakaza + " руб.\n");
  132.  
  133.                 kassa = kassa + summa_zakaza;
  134.                
  135.  
  136.                 Console.WriteLine("\n\n\nЧто то еще?\n" +
  137.                     "1.да\n" +
  138.                     "2.нет");
  139.                 vibor = Console.ReadLine();
  140.  
  141.                 if (vibor == "2")
  142.                 {
  143.                     ves_zakaz = true;
  144.                 }
  145.                 else if (vibor !="1" && vibor!="2")
  146.                 {
  147.                     Console.WriteLine("Ошибка ввода");
  148.                     Console.ReadKey();
  149.  
  150.                 }
  151.             }
  152.            
  153.             Console.WriteLine("Нажми любую кнопку для возврата в меню...");
  154.             Console.ReadKey();        
  155.  
  156.            
  157.         }
  158.  
  159.  
  160.  
  161.  
  162.  
  163.         static void Menu(string [] tovar , int[] ostatok, int [] price, string name , int summa_zakaza , int kassa)
  164.         {
  165.             Begin(tovar, price ,name);
  166.  
  167.  
  168.            
  169.  
  170.             bool end_work = false;
  171.             string command = "0";
  172.  
  173.             while (!end_work)
  174.             {
  175.                 Console.Clear();
  176.  
  177.                 Console.SetCursorPosition(30, 0);
  178.                 Console.Write("Сумма в кассе: " + kassa);
  179.  
  180.                 Console.SetCursorPosition(0, 0);
  181.                 Console.Write("1. Заказ " +
  182.                 "\n2. Складской остаток " +
  183.                 "\n3. Зарыть");
  184.  
  185.                 Console.WriteLine("\n\nВводи номер команды:");
  186.                 command = Console.ReadLine();
  187.                
  188.  
  189.  
  190.                
  191.  
  192.                 switch (command)
  193.                 {
  194.                     case "1":
  195.                         Console.Clear();
  196.                         Zakaz(ref tovar, ref price, ref kassa, ref summa_zakaza,ref ostatok);
  197.  
  198.                         break;
  199.  
  200.  
  201.                     case "2":
  202.                         Console.Clear();
  203.                         Sklad(ref tovar,ref ostatok);
  204.                         break;
  205.  
  206.  
  207.                     case "3":
  208.                         end_work = true;
  209.                         break;
  210.                 }
  211.  
  212.  
  213.  
  214.  
  215.  
  216.             }
  217.  
  218.  
  219.  
  220.  
  221.  
  222.         }
  223.     }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement