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.IO;
- namespace Game
- {
- class Program
- {
- static Invertory[] Invertory = new Invertory[0];
- static string[] Shop = File.ReadAllLines("Shop.txt");
- static Shop[] ShopItems = new Shop[Shop.Length];
- static void Main(string[] args)
- {
- Console.WriteLine("Мы идем в магазин или идем в инвертарь?");
- int change = int.Parse(Console.ReadLine());
- if (change == 1)
- {
- DisplayShop();
- }
- if (change == 2)
- {
- DisplayInvertory();
- }
- Console.ReadKey();
- }
- private static void DisplayInvertory()
- {
- if (Invertory.Length == 0)
- {
- Console.WriteLine("У вас пустой инвертарь!");
- }
- else
- {
- for (int i = 0; i < Invertory.Length; i++)
- {
- Console.WriteLine($"{i + 1}) {Invertory[i].Name} {Invertory[i].Type} {Invertory[i].Description} {Invertory[i].Price} {Invertory[i].Rarity}");
- }
- }
- }
- private static void DisplayShop()
- {
- int Number = 0;
- int i = 0;
- foreach (string Line in Shop)
- {
- string[] Parts = Line.Split(';');
- ShopItems[i] = new Shop();
- ShopItems[i].Name = Parts[0];
- ShopItems[i].Type = Parts[1];
- ShopItems[i].Description = Parts[2];
- ShopItems[i].Price = int.Parse(Parts[3]);
- ShopItems[i].Rarity = Parts[4];
- i++;
- }
- Console.WriteLine("Добро поржаловать в наш магазин!\nВот наш ассортимент!\n");
- for (i = 0; i < Shop.Length; i++)
- {
- Console.WriteLine($"{i + 1}) {ShopItems[i].Name} {ShopItems[i].Type} {ShopItems[i].Description } {ShopItems[i].Price } {ShopItems[i].Rarity}");
- }
- Console.WriteLine();
- Console.WriteLine("Чтобы бы вы хотели бы приобрести?");
- Number = int.Parse(Console.ReadLine()) - 1;
- BuyItems(Number);
- DisplayInvertory();
- }
- private static void BuyItems(int Number)
- {
- Array.Resize(ref Invertory, Invertory.Length + 1);
- Invertory[Invertory.Length - 1] = ShopItems[Number];
- }
- }
- }
Add Comment
Please, Sign In to add comment