Advertisement
program12

Untitled

Jun 11th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 KB | None | 0 0
  1.         private string price;
  2.         private string name;
  3.  
  4.         public string Name { get => name; set => name = value; }
  5.         public string Price { get => price; set => price = value; }
  6.         public string City { get => city; set => city = value; }
  7.     }
  8.     class Program
  9.     {
  10.         static void PartyInsert(List<party> parties)
  11.         {
  12.             string sName;
  13.             string sCity;
  14.             string sPrice;
  15.             Console.Clear();
  16.             Console.WriteLine("Podaj nazwę imprezy: ");
  17.             sName = Console.ReadLine();
  18.             Console.WriteLine("Podaj Miasto: ");
  19.             sCity = Console.ReadLine();
  20.             Console.WriteLine("Podaj cenę wejściówki imprezy: ");
  21.             sPrice = Console.ReadLine();
  22.             parties.Add(new party() { City = sCity, Price = sPrice, Name = sName });
  23.             Console.WriteLine("Impreza Dodana");
  24.         }
  25.  
  26.         static void Main(string[] args)
  27.         {
  28.             List<party> parties = new List<party>();
  29.             string caseSwitch;
  30.             bool end = false;
  31.             string userCity;
  32.             for(;end!=true;)
  33.             {
  34.                 Console.WriteLine("Wybierz opcję\n 1. Dodawanie imprezy\n 2. Szukanie Imprezy\n 3. Wyłącz Aplikacje");
  35.                 caseSwitch = Console.ReadLine();
  36.                 switch (caseSwitch)
  37.                 {
  38.                     case "1":
  39.                         PartyInsert(parties);
  40.                         break;
  41.                     case "2":
  42.                         Console.WriteLine("Wpisz nazwę miasta w którym się znajdujesz: ");
  43.                         userCity = Console.ReadLine();
  44.                         Console.Clear();
  45.                         Console.WriteLine("Imprezy w mieście którym się znajdujesz: ");
  46.                         foreach (party aPart in parties)
  47.                         {
  48.                             if(userCity == aPart.City)
  49.                             {
  50.                                 Console.WriteLine("Nazwa imprezy: " + aPart.Name + "\nCena wejścówki: " + aPart.Price + "\nMiejscowosc: " + aPart.City + "\n\n");
  51.                             }
  52.                         }
  53.                         Console.WriteLine("Imprezy z poza twojego miasta: ");
  54.                         foreach (party aPart in parties)
  55.                         {
  56.                             if (userCity != aPart.City)
  57.                             {
  58.                                 Console.WriteLine("Nazwa imprezy: " + aPart.Name + "\nCena wejścówki: " + aPart.Price + "\nMiejscowosc: " + aPart.City + "\n\n");
  59.                             }
  60.                         }
  61.                         break;
  62.                     default:
  63.                         Console.WriteLine("Default case");
  64.                         end = true;
  65.                         break;
  66.                 }
  67.             }
  68.             foreach (party aPart in parties)
  69.             {
  70.                 Console.WriteLine("Nazwa imprezy: " + aPart.Name + "\nCena wejścówki: " + aPart.Price + "\nMiejscowosc: " + aPart.City + "\n\n");
  71.             }
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement