- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zaliczenie_kolos
- {
- class filmy
- {
- public double cena;
- public string title;
- public string name;
- public string lastname;
- public int lenght;
- public override string ToString()
- {
- return title+" " + name + " " + lastname+" "+lenght+" "+cena;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- void menu()
- {
- Console.WriteLine("1.Tablica liczb rzeczywistych");
- Console.WriteLine("2.Tablica tekstów");
- Console.WriteLine("3.Dodaj filmy");
- Console.WriteLine("4.Najtrótszy i najdłuższy film");
- Console.WriteLine("5.Szukaj film");
- Console.WriteLine("6.Szukaj reżysera");
- Console.WriteLine("7.Wyjście");
- }
- List<filmy> Filmy = new List<filmy>();
- int abc = 0;
- int[] tab ;
- string[] zad2;
- void searchbytitle(string a)
- {
- int c = 0;
- for (int i = 0; i < Filmy.Count(); i++)
- {
- if (Filmy[i].title==a)
- {
- Console.WriteLine(Filmy[i]);
- c = 1;
- }
- }
- if (c==0)
- {
- Console.WriteLine("brak filmu");
- }
- }
- void searchbyname(string a) {
- int c = 0;
- for (int i = 0; i < Filmy.Count(); i++)
- {
- if (Filmy[i].lastname == a)
- {
- Console.WriteLine(Filmy[i]);
- c = 1;
- }
- }
- if (c == 0)
- {
- Console.WriteLine("brak filmu");
- }
- }
- void minmaxmovie()
- {
- int min =Filmy[0].lenght;
- int max=Filmy[0].lenght;
- for (int i = 0; i < Filmy.Count(); i++)
- {
- if (Filmy[i].lenght<min)
- {
- min = Filmy[i].lenght;
- }
- if (Filmy[i].lenght > max)
- {
- max = Filmy[i].lenght;
- }
- }
- for (int i = 0; i < Filmy.Count(); i++)
- {
- if (Filmy[i].lenght==min)
- {
- Console.WriteLine("Najkrótszy film: " + Filmy[i]);
- }
- if (Filmy[i].lenght == max)
- {
- Console.WriteLine("Najdłuższy film: " + Filmy[i]);
- }
- }
- }
- void zad1(int a, int b, int c)
- {
- tab[a] = b;
- if (a==(c-1))
- {
- Console.WriteLine(tab.Min()+"-Minimalna liczba");
- Console.WriteLine(tab.Max()+"-Maksymalna liczba");
- }
- }
- void Zad2(int a, string b, int c,string d)
- {
- int t = -1;
- zad2[a] = b;
- if(zad2[a]==d)
- {
- Console.WriteLine("Słowo "+d+" Znajduje się w :"+(a+1)+" pozycji");
- t = 0;
- }
- if(a==(c-1) && t==-1)
- {
- Console.WriteLine(t);
- }
- }
- Filmy.Add(new filmy() { cena = 40.20, title = "Indiana Jones", name = "Karol", lastname = "Wojtyła", lenght = 145 });
- Filmy.Add(new filmy() { cena = 40.20, title = "Mój przyjaciel smok", name = "Karol", lastname = "Szramski", lenght = 148 });
- Filmy.Add(new filmy() { cena = 40.20, title = "Kubuś puchatek", name = "Katarzyna", lastname = "Wałowska", lenght = 145 });
- Filmy.Add(new filmy() { cena = 40.20, title = "Nikt nie spodziewał się tej śmierci", name = "Stan", lastname = "Lee", lenght = 143 });
- Main:
- Console.Clear();
- int akcja1;
- menu();
- while(!Int32.TryParse(Console.ReadLine(),out akcja1) || akcja1>7 || akcja1<1)
- {
- Console.Clear();
- Console.WriteLine("Podaj poprawny znak!n");
- menu();
- }
- switch(akcja1)
- {
- case 1:
- Console.WriteLine("Rozmiar talbicy?");
- abc = Convert.ToInt32(Console.ReadLine());
- tab = new int[abc];
- for (int i = 0; i < abc; i++)
- {
- Console.WriteLine("Podaj liczbe");
- int liczba = Convert.ToInt32(Console.ReadLine());
- zad1(i, liczba,abc);
- }
- Console.WriteLine("Click any button to go back to menu");
- Console.ReadKey();
- goto Main;
- case 2:
- Console.WriteLine("Rozmiar talbicy?");
- abc = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Szukane słowo");
- string slowo = Console.ReadLine();
- zad2 = new string[abc];
- for (int i = 0; i < abc; i++)
- {
- Console.WriteLine("Podaj tekst");
- string zad2tekst = Console.ReadLine();
- Zad2(i, zad2tekst, abc,slowo);
- }
- Console.WriteLine("Click any button to go back to menu");
- Console.ReadKey();
- goto Main;
- case 3:
- Console.WriteLine("Podaj tytul");
- string tilte = Console.ReadLine();
- Console.WriteLine("Podał długość filmu");
- int lenght = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("podaj imie autora");
- string name = Console.ReadLine();
- Console.WriteLine("Podaj naziwsko autora");
- string lastname = Console.ReadLine();
- Console.WriteLine("podaj cene filmu");
- double price = Convert.ToDouble(Console.ReadLine());
- Filmy.Add(new filmy() { cena = price, title = tilte, name = name, lastname = lastname, lenght = lenght });
- Console.WriteLine("Film dodany pomyślnie");
- goto Main;
- case 4:
- minmaxmovie();
- Console.ReadLine();
- goto Main;
- case 5:
- Console.WriteLine("Podaj tytuł");
- string a = Console.ReadLine();
- searchbytitle(a);
- Console.ReadLine();
- goto Main;
- case 6:
- Console.WriteLine("Podaj nazwisko");
- string b = Console.ReadLine();
- searchbyname(b);
- Console.ReadLine();
- goto Main;
- case 7:
- break;
- }
- Console.ReadLine();
- }
- }
- }