Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Client
  5. {
  6.     public string name { get; set; }
  7.     public string comp { get; set; }
  8.     public string ip { get; set; }
  9.    
  10.     public Client()
  11.     {
  12.            
  13.     }
  14.    
  15.     public Client(string name, string comp, string ip)
  16.     {
  17.         this.name = name;
  18.         this.comp = comp;
  19.         this.ip = ip;      
  20.     }
  21. }
  22.  
  23.  
  24.                    
  25. public class Program
  26. {
  27.    
  28.    
  29.     public static void Main()
  30.     {
  31.         List<Client> Clients = new List<Client>();
  32.        
  33.         MenuStart();
  34.        
  35.         //dodaj do listy - Clients
  36.     }
  37.     public static void AddClient(List<Client> CLients) 
  38.     {
  39.         Console.Write("Podaj nazwe klienta: ");
  40.         string nameC = Console.ReadLine();
  41.         Console.Write("Podaj nazwe firmy klienta: ");
  42.         string comp = Console.ReadLine();
  43.         Console.Write("Podaj adres ip klienta: ");
  44.         string ip = Console.ReadLine();
  45.         Clients.Add(new Client(nameC, comp, ip));
  46.         resQuestion();
  47.     }
  48.    
  49.     public static void resQuestion()
  50.     {
  51.         Console.WriteLine("Klient zostal dodany");
  52.         Console.Write("Czy chcesz dodac kolejnego klienta do listy?  Y/N: ");
  53.         string nothC = Console.ReadLine();
  54.             if(nothC == "Y")
  55.             {
  56.                 AddClient(Clients);
  57.             } else
  58.             {
  59.                 Console.Clear();
  60.                 MenuStart();
  61.             }
  62.     }
  63.    
  64.     public static void ShowAll(List<Client> name)
  65.     {
  66.         foreach(object client in name)
  67.         {
  68.        
  69.         }
  70.     }
  71.        
  72.     public static void MenuStart()
  73.     {
  74.         Console.WriteLine("MENU WYBORU:");
  75.         Console.WriteLine("1. Dodaj nowego klienta.");
  76.         Console.WriteLine("2. Modyfikacja elementu.");
  77.         Console.WriteLine("3. Usunięcie elementu.");
  78.         Console.WriteLine("4. wyswietl elementy.");
  79.         string strC = Console.ReadLine();
  80.        
  81.                 switch (strC)
  82.         {
  83.             case "1":
  84.                 AddClient(Clients);
  85.                 break;
  86.                
  87.             case "2":
  88.                 Console.WriteLine(5);
  89.                 break;
  90.                
  91.             case "3":
  92.                 Console.WriteLine(5);
  93.                 break;
  94.                        
  95.             case "4":
  96.                     ShowAll2(Clients);
  97.                 break;
  98.                        
  99.             // Walidacja
  100.         }
  101.     }
  102.    
  103.     static void ShowAll2(List<Client> name)
  104.     {
  105.         name.ForEach(i => Console.Write("{0},{1},{2}", i.name, i.comp, i.ip));
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement