Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 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.     private static List<Client> Clients = new List<Client>();
  29.  
  30.     public static void Main()
  31.     {
  32.         MenuStart();
  33.  
  34.         //dodaj do listy - Clients
  35.     }
  36.     public static void AddClient(List<Client> Cients)
  37.     {
  38.         Console.Write("Podaj nazwe klienta: ");
  39.         string nameC = Console.ReadLine();
  40.         Console.Write("Podaj nazwe firmy klienta: ");
  41.         string comp = Console.ReadLine();
  42.         Console.Write("Podaj adres ip klienta: ");
  43.         string ip = Console.ReadLine();
  44.         Clients.Add(new Client(nameC, comp, ip));
  45.         resQuestion();
  46.     }
  47.  
  48.     public static void resQuestion()
  49.     {
  50.         Console.WriteLine("Klient zostal dodany");
  51.         Console.Write("Czy chcesz dodac kolejnego klienta do listy?  Y/N: ");
  52.         string nothC = Console.ReadLine();
  53.         if (nothC == "Y")
  54.         {
  55.             AddClient(Clients);
  56.         }
  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.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement