Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- using System.IO;
- namespace Lesson5
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] tovar = { "Орешки", "Пиво", "Сухарики", "Сидр", "Семечки", "Чипсы" };
- int[] price = { 15, 50, 15, 65, 10, 30 };
- int[] ostatok = { 50, 50, 30, 60, 23, 15 };
- string name = "";
- int summa_zakaza = 0;
- int kassa = 0;
- Menu( tovar, ostatok, price,name, summa_zakaza,kassa);
- }
- static void Begin(string [] tovar,int [] price,string name)
- {
- Console.WriteLine("Введите имя оператора: ");
- name = Console.ReadLine();
- Console.Clear();
- Console.WriteLine("Теперь ты новый продавец в этой пивной!\nТак вот, " + name + ", тебе предстоит продавать:\n ");
- for (int i = 0; i < tovar.Length; i++)
- {
- string position = tovar[i];
- string stoimost = Convert.ToString(price[i]);
- Console.WriteLine(position + " за " + stoimost + " руб.\n");
- }
- Console.WriteLine();
- Console.WriteLine("Нажми любую клавишу и приступай!\nУдачи!");
- Console.ReadKey();
- Console.Clear();
- //return name;
- }
- static void Sklad(ref string[] tovar,ref int [] ostatok)
- {
- Console.Clear();
- Console.WriteLine("Остатки:\n");
- for (int i = 0; i < tovar.Length; i++)
- {
- string position = tovar[i];
- string Sklad_ostatok = Convert.ToString(ostatok[i]);
- Console.Write(position + " - " + Sklad_ostatok + " Ед.\n");
- }
- Console.WriteLine();
- Console.WriteLine("Нажми любую клавишу для возврата в меню...");
- Console.ReadKey();
- Console.Clear();
- }
- static void Zakaz(ref string[] tovar,ref int [] price,ref int kassa , ref int summa_zakaza, ref int[] ostatok)
- {
- bool ves_zakaz = false;
- string vibor;
- string tovar_zakaz;
- int num_tovar_zakaz = 0;
- int x = 42, y = 2;
- Console.WriteLine("Создай заказ: ");
- while (!ves_zakaz)
- {
- Console.Clear();
- Console.SetCursorPosition(0, 0);
- Console.Write("Товар: ");
- tovar_zakaz = Console.ReadLine();
- Console.Write("Кол-во товара в заказе: ");
- num_tovar_zakaz = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < tovar.Length; i++)
- {
- if (tovar[i].ToLower().StartsWith(tovar_zakaz))
- {
- if (num_tovar_zakaz > ostatok[i])
- {
- Console.WriteLine("Указанное кол-во превышает складской остаток\n" +
- "Запрашиваемого товара на складе: "+ ostatok[i]);
- }
- else
- {
- ostatok[i] = ostatok[i] - num_tovar_zakaz;
- summa_zakaza += (price[i] * num_tovar_zakaz);
- }
- }
- }
- Console.Write("Сумма заказа - " + summa_zakaza + " руб.\n");
- kassa = kassa + summa_zakaza;
- Console.WriteLine("\n\n\nЧто то еще?\n" +
- "1.да\n" +
- "2.нет");
- vibor = Console.ReadLine();
- if (vibor == "2")
- {
- ves_zakaz = true;
- }
- else if (vibor !="1" && vibor!="2")
- {
- Console.WriteLine("Ошибка ввода");
- Console.ReadKey();
- }
- }
- Console.WriteLine("Нажми любую кнопку для возврата в меню...");
- Console.ReadKey();
- }
- static void Menu(string [] tovar , int[] ostatok, int [] price, string name , int summa_zakaza , int kassa)
- {
- Begin(tovar, price ,name);
- bool end_work = false;
- string command = "0";
- while (!end_work)
- {
- Console.Clear();
- Console.SetCursorPosition(30, 0);
- Console.Write("Сумма в кассе: " + kassa);
- Console.SetCursorPosition(0, 0);
- Console.Write("1. Заказ " +
- "\n2. Складской остаток " +
- "\n3. Зарыть");
- Console.WriteLine("\n\nВводи номер команды:");
- command = Console.ReadLine();
- switch (command)
- {
- case "1":
- Console.Clear();
- Zakaz(ref tovar, ref price, ref kassa, ref summa_zakaza,ref ostatok);
- break;
- case "2":
- Console.Clear();
- Sklad(ref tovar,ref ostatok);
- break;
- case "3":
- end_work = true;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement