Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4.  
  5.  
  6.                    
  7. public class Program
  8. {  
  9.     static string strC = "";
  10.    
  11.     public static void Main()
  12.     {
  13.         List<Piec> piece = new List<Piec>();
  14.         MenuStart();           
  15.        
  16.     }
  17.    
  18.     static void AddProp(List<Piec> name)
  19.     {  
  20.         name.Add(new Piec(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), Console.ReadLine(), Console.ReadLine()));
  21.         Console.WriteLine("Element zostal dodany");
  22.         Console.Write("Czy chcesz dodac kolejny elemento do listy?  Y/N: ");
  23.         string nothC = Console.ReadLine();
  24.             if(nothC == "Y")
  25.             {
  26.                 string listName = name.ToString();
  27.                 var dict = new Dictionary<string, List<Piec>>();
  28.                 dict[listName] = new List<Piec>();     
  29.                 AddProp(dict[listName]);
  30.                
  31.             } else
  32.             {
  33.                 MenuStart();
  34.             }
  35.     }  
  36.    
  37.         static void ShowAll(List<Piec> name)
  38.     {
  39.         name.ForEach(i => Console.Write("{0},{1},{2},{3}", i.id, i.ip, i.name, i.web));
  40.     }
  41.    
  42.  
  43.     static void MenuStart()
  44.     {
  45.         Console.WriteLine("MENU WYBORU:");
  46.         Console.WriteLine("1. Dodaj nowy element.");
  47.         Console.WriteLine("2. Modyfikacja elementu.");
  48.         Console.WriteLine("3. Usunięcie elementu.");
  49.         Console.WriteLine("4. wyswietl elementy.");
  50.         strC = Console.ReadLine();
  51.        
  52.                 switch (strC)
  53.         {
  54.             case "1":
  55.             Console.WriteLine("Podaj nazwę listy:");
  56.                 string listName = Console.ReadLine();
  57.                 var dict = new Dictionary<string, List<Piec>>();
  58.                 dict[listName] = new List<Piec>();     
  59.                 AddProp(dict[listName]);
  60.                 break;
  61.                
  62.             case "2":
  63.                 Console.WriteLine(5);
  64.                 break;
  65.                
  66.             case "3":
  67.                 Console.WriteLine(5);
  68.                 break;
  69.                        
  70.             case "4":
  71.                 Console.Write("Wpisz nazwe listy ktora ma zostac wyswietlona: ");
  72.                 string setlistName = Console.ReadLine();
  73.                 var dict2 = new Dictionary<string, List<Piec>>();
  74.                 ShowAll(dict2[setlistName]);
  75.                 break;
  76.                        
  77.             // Walidacja
  78.         }
  79.        
  80.     }
  81.    
  82.  
  83. }
  84.  
  85.  
  86. public class Piec
  87. {
  88.     public int id { get; set; }
  89.     public int ip { get; set; }
  90.     public string name { get; set; }
  91.     public string web { get; set; }
  92.    
  93.    
  94.     public Piec(int id, int ip, string name, string web)
  95.     {
  96.         this.id= id;
  97.         this.ip = ip;
  98.         this.name = name;
  99.         this.web = web;
  100.     }
  101.    
  102.  
  103.    
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement