Facebook
From Ja, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 237
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Zaliczenie_kolos
  8. {
  9.     class filmy
  10.     {
  11.         public double cena;
  12.         public string title;
  13.         public string name;
  14.         public string lastname;
  15.         public int lenght;
  16.         public override string ToString()
  17.         {
  18.             return title+" " + name + " " + lastname+" "+lenght+" "+cena;
  19.         }
  20.     }
  21.  
  22.     class Program
  23.     {
  24.         static void Main(string[] args)
  25.         {
  26.  
  27.             void menu()
  28.             {
  29.                 Console.WriteLine("1.Tablica liczb rzeczywistych");
  30.                 Console.WriteLine("2.Tablica tekstów");
  31.                 Console.WriteLine("3.Dodaj filmy");
  32.                 Console.WriteLine("4.Najtrótszy i najdłuższy film");
  33.                 Console.WriteLine("5.Szukaj film");
  34.                 Console.WriteLine("6.Szukaj reżysera");
  35.                 Console.WriteLine("7.Wyjście");
  36.             }
  37.             List<filmy> Filmy = new List<filmy>();
  38.             int abc = 0;
  39.             int[] tab  ;
  40.             string[] zad2;
  41.             void searchbytitle(string a)
  42.             {
  43.                 int c = 0;
  44.                 for (int i = 0; i < Filmy.Count(); i++)
  45.                 {
  46.                     if (Filmy[i].title==a)
  47.                     {
  48.                         Console.WriteLine(Filmy[i]);
  49.                         c = 1;
  50.                     }
  51.                 }
  52.                 if (c==0)
  53.                 {
  54.                     Console.WriteLine("brak filmu");
  55.                 }
  56.             }
  57.             void searchbyname(string a) {
  58.                 int c = 0;
  59.                 for (int i = 0; i < Filmy.Count(); i++)
  60.                 {
  61.                     if (Filmy[i].lastname == a)
  62.                     {
  63.                         Console.WriteLine(Filmy[i]);
  64.                         c = 1;
  65.                     }
  66.                 }
  67.                 if (c == 0)
  68.                 {
  69.                     Console.WriteLine("brak filmu");
  70.                 }
  71.             }
  72.             void minmaxmovie()
  73.             {
  74.                 int min =Filmy[0].lenght;
  75.                 int max=Filmy[0].lenght;
  76.                
  77.                 for (int i = 0; i < Filmy.Count(); i++)
  78.                 {
  79.                     if (Filmy[i].lenght<min)
  80.                     {
  81.                         min = Filmy[i].lenght;
  82.                     }
  83.                     if (Filmy[i].lenght > max)
  84.                     {
  85.                         max = Filmy[i].lenght;
  86.                     }
  87.                    
  88.                 }
  89.                 for (int i = 0; i < Filmy.Count(); i++)
  90.                 {
  91.                     if (Filmy[i].lenght==min)
  92.                     {
  93.                         Console.WriteLine("Najkrótszy film: " + Filmy[i]);
  94.                     }
  95.                     if (Filmy[i].lenght == max)
  96.                     {
  97.                         Console.WriteLine("Najdłuższy film: " + Filmy[i]);
  98.                     }
  99.                 }
  100.  
  101.                
  102.             }
  103.             void zad1(int a, int b, int c)
  104.             {
  105.                 tab[a] = b;
  106.                 if (a==(c-1))
  107.                 {
  108.                     Console.WriteLine(tab.Min()+"-Minimalna liczba");
  109.                     Console.WriteLine(tab.Max()+"-Maksymalna liczba");
  110.                 }
  111.             }
  112.             void Zad2(int a, string b, int c,string d)
  113.             {
  114.                 int t = -1;
  115.                 zad2[a] = b;
  116.                 if(zad2[a]==d)
  117.                 {
  118.                     Console.WriteLine("Słowo "+d+" Znajduje się w :"+(a+1)+" pozycji");
  119.                     t = 0;
  120.                 }
  121.                 if(a==(c-1) && t==-1)
  122.                 {
  123.                     Console.WriteLine(t);
  124.                 }
  125.  
  126.             }
  127.             Filmy.Add(new filmy() { cena = 40.20, title = "Indiana Jones", name = "Karol", lastname = "Wojtyła", lenght = 145 });
  128.             Filmy.Add(new filmy() { cena = 40.20, title = "Mój przyjaciel smok", name = "Karol", lastname = "Szramski", lenght = 148 });
  129.             Filmy.Add(new filmy() { cena = 40.20, title = "Kubuś puchatek", name = "Katarzyna", lastname = "Wałowska", lenght = 145 });
  130.             Filmy.Add(new filmy() { cena = 40.20, title = "Nikt nie spodziewał się tej śmierci", name = "Stan", lastname = "Lee", lenght = 143 });
  131.         Main:
  132.             Console.Clear();
  133.             int akcja1;
  134.             menu();
  135.             while(!Int32.TryParse(Console.ReadLine(),out akcja1) || akcja1>7 || akcja1<1)
  136.             {
  137.                 Console.Clear();
  138.                 Console.WriteLine("Podaj poprawny znak!n");
  139.                     menu();
  140.             }
  141.             switch(akcja1)
  142.             {
  143.             case 1:
  144.                     Console.WriteLine("Rozmiar talbicy?");
  145.                     abc = Convert.ToInt32(Console.ReadLine());
  146.                     tab = new int[abc];
  147.                     for (int i = 0; i < abc; i++)
  148.                     {
  149.                         Console.WriteLine("Podaj liczbe");
  150.                         int liczba = Convert.ToInt32(Console.ReadLine());
  151.                         zad1(i, liczba,abc);
  152.                     }
  153.  
  154.                     Console.WriteLine("Click any button to go back to menu");
  155.                     Console.ReadKey();
  156.                 goto Main;
  157.             case 2:
  158.                     Console.WriteLine("Rozmiar talbicy?");
  159.                    
  160.  
  161.                     abc = Convert.ToInt32(Console.ReadLine());
  162.                     Console.WriteLine("Szukane słowo");
  163.                     string slowo = Console.ReadLine();
  164.                     zad2 = new string[abc];
  165.                     for (int i = 0; i < abc; i++)
  166.                     {
  167.                         Console.WriteLine("Podaj tekst");
  168.                         string zad2tekst = Console.ReadLine();
  169.                         Zad2(i, zad2tekst, abc,slowo);
  170.                     }
  171.  
  172.                     Console.WriteLine("Click any button to go back to menu");
  173.                     Console.ReadKey();
  174.                     goto Main;
  175.             case 3:
  176.                     Console.WriteLine("Podaj tytul");
  177.                     string tilte = Console.ReadLine();
  178.                     Console.WriteLine("Podał długość filmu");
  179.                     int lenght = Convert.ToInt32(Console.ReadLine());
  180.                     Console.WriteLine("podaj imie autora");
  181.                     string name = Console.ReadLine();
  182.                     Console.WriteLine("Podaj naziwsko autora");
  183.                     string lastname = Console.ReadLine();
  184.                     Console.WriteLine("podaj cene filmu");
  185.                     double price = Convert.ToDouble(Console.ReadLine());
  186.                     Filmy.Add(new filmy() { cena = price, title = tilte, name = name, lastname = lastname, lenght = lenght });
  187.                     Console.WriteLine("Film dodany pomyślnie");
  188.  
  189.                     goto Main;
  190.             case 4:
  191.                     minmaxmovie();
  192.                     Console.ReadLine();
  193.                 goto Main;
  194.             case 5:
  195.                     Console.WriteLine("Podaj tytuł");
  196.                     string a = Console.ReadLine();
  197.                     searchbytitle(a);
  198.                     Console.ReadLine();
  199.                 goto Main;
  200.             case 6:
  201.                     Console.WriteLine("Podaj nazwisko");
  202.                     string b = Console.ReadLine();
  203.                     searchbyname(b);
  204.                     Console.ReadLine();
  205.                     goto Main;
  206.             case 7:
  207.                 break;
  208.             }
  209.             Console.ReadLine();
  210.         }
  211.     }
  212. }