HaoAsakura

1

Sep 25th, 2023
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace TestFieldIthink
  5. {
  6.     public struct Storage
  7.     {
  8.         public string Name;
  9.         public int Size;
  10.         public List<string> items;
  11.  
  12.         private void ShowContent()
  13.         {
  14.             Console.Write("\n[*] Склад содержит следующие предметы: ");
  15.  
  16.             for (int i = 0; i < items.Count; i++)
  17.                 Console.Write(items[i] + ", ");
  18.  
  19.             Console.WriteLine();
  20.         }
  21.  
  22.         public void Add()
  23.         {
  24.             Console.Write("[*] Введите вместимость склада: ");
  25.             this.Size = int.Parse(Console.ReadLine());
  26.  
  27.             for(int i = 0; i < Size; ++i)
  28.             {
  29.                 Console.Write($"\n[*] Введите {i + 1} предмет: ");
  30.                 string item = Console.ReadLine();
  31.                 items.Add(item);
  32.             }
  33.  
  34.             ShowContent();
  35.         }
  36.  
  37.         public void Delete(string item)
  38.         {
  39.             try { items.Remove(item); ShowContent(); }
  40.             catch { }
  41.         }
  42.  
  43.     }
  44.  
  45.    
  46.  
  47.     internal class Program
  48.     {
  49.         static void Main(string[] args)
  50.         {
  51.             List<Storage> storageList = new List<Storage>();
  52.  
  53.             Storage fruits = new Storage();
  54.  
  55.             fruits.items = new List<string>();
  56.  
  57.             fruits.Add();
  58.         }
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment