Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.97 KB | None | 0 0
  1. class Wydzial
  2.     {
  3.         private List<Przedmiot> przedmiots = new List<Przedmiot>();
  4.         private List<Student> students = new List<Student>();
  5.         private List<Jednostka> jednostkas = new List<Jednostka>();
  6.        
  7.         public void DodajJednostke(string nazwa_, string adres_)
  8.         {
  9.             Jednostka j = new Jednostka(nazwa_, adres_);
  10.             jednostkas.Add(j);
  11.         }
  12.  
  13.         public void DodajPrzedmiot(Przedmiot p)
  14.         {
  15.             przedmiots.Add(p);
  16.         }
  17.  
  18.         public void DodajStudenta(Student s)
  19.         {
  20.             students.Add(s);
  21.         }
  22.  
  23.         public bool DodajWykladowce(Wykladowca w, string nazwaJednostki_)
  24.         {
  25.             foreach(var item in jednostkas)
  26.             {
  27.                 if (item.Nazwa == nazwaJednostki_)
  28.                 {
  29.                     item.DodajWykladowce(w);
  30.                     return true;
  31.                 }
  32.             }
  33.             return false;
  34.         }
  35.  
  36.         public bool DodajOcene(int nrIndeksu_, string nazwaPrzedmiotu_, double ocena_, string data_, Przedmiot p)
  37.         {
  38.             foreach(var item in przedmiots)
  39.             {
  40.                 if (item.Nazwa == nazwaPrzedmiotu_)
  41.                 {
  42.                     foreach(var item1 in students)
  43.                     {
  44.                         if (item1.NrIndeksu == nrIndeksu_)
  45.                         {
  46.                             item1.DodajOcene(p,ocena_,data_);
  47.                             return true;
  48.                         }
  49.                     }
  50.                 }
  51.             }
  52.             return false;
  53.         }
  54.  
  55.         public bool UsunStudenta(int nrIndeksu_)
  56.         {
  57.             for(int i = 0; i < students.Count; i++)
  58.             {
  59.                 Student s = students[i];
  60.                 if(s.NrIndeksu == nrIndeksu_)
  61.                 {
  62.                     students.RemoveAt(i);
  63.                     return true;
  64.                 }
  65.             }
  66.             return false;
  67.         }
  68.  
  69.         public bool PrzeniesWykladowce(Wykladowca w, string obecnaJednostka, string nowaJednostka)
  70.         {
  71.             if (jednostkas.Find(x => x.Nazwa== obecnaJednostka) == null || jednostkas.Find(x => x.Nazwa == nowaJednostka) == null)
  72.             {
  73.                 Console.WriteLine("Nie znaleziono takich jednostek bądź wykładowcy");
  74.                 return false;
  75.             }
  76.             jednostkas.Find(x => x.Nazwa == obecnaJednostka).UsunWykladowce(w);
  77.             jednostkas.Find(x => x.Nazwa== nowaJednostka).DodajWykladowce(w);
  78.             return true;
  79.         }
  80.  
  81.         public bool InfoStudenci(bool infoOceny)
  82.         {   /*
  83.             foreach (var item in students)
  84.             {
  85.                 item.WypiszInfo();
  86.             }
  87.             */
  88.  
  89.             for(int i = 0; i < students.Count; i++)
  90.             {
  91.                 Console.WriteLine("Student Nr " + (i+1));
  92.                 students[i].WypiszInfo();
  93.                 if (infoOceny == true)
  94.                 {  
  95.                     students[i].InfoOceny();
  96.                 }
  97.             }
  98.             return false;
  99.         }
  100.        
  101.  
  102.        
  103.         public bool InfoPrzedmioty()
  104.         {/*
  105.             foreach(var item in przedmiots)
  106.             {
  107.                item.WypiszInfo();
  108.             }
  109.             */
  110.             for(int i = 0; i < przedmiots.Count; i++)
  111.             {
  112.                 przedmiots[i].WypiszInfo();
  113.  
  114.             }
  115.  
  116.             return false;
  117.         }
  118.  
  119.         public bool InfoJednostki(bool infoWykladowcy)
  120.         {
  121.             for(int i = 0; i < jednostkas.Count; i++)
  122.             {
  123.                 jednostkas[i].WypiszInfo();
  124.                 if (infoWykladowcy == true)
  125.                 {
  126.                     jednostkas[i].InfoWykladowcy();
  127.                 }
  128.             }
  129.             return false;
  130.         }
  131.  
  132.  
  133.  
  134.     }
  135.  
  136.     class Program
  137.     {
  138.         static void Main(string[] args)
  139.         {
  140.             Student student1 = new Student("Wiktor", "Kibało", "24.02.1998", "Informatyka", "Sieci Komputerowe", 1, 1, 123123);
  141.             Student student2 = new Student("Ferdynand", "Kiepski", "01.03.1997", "Matematyka", "Matematyka Finansowa", 3, 2, 321312);
  142.             Student student3 = new Student("Piotr", "Schmidt", "03.05.1995", "Informatyka", "Sieci Komputerowe", 1, 2, 765123);
  143.             Przedmiot subject1 = new Przedmiot("Programowanie obiektowe", "Informatyka","Sieci Komputerowe", 4, 30);
  144.             Przedmiot subject2 = new Przedmiot("Systemy Operacyjne", "Informatyka", "Sieci Komputerowe", 4, 30);
  145.             Przedmiot subject3 = new Przedmiot("Matematyka Dyskretna", "Matematyka", "Matematyka Finansowa", 1, 15);
  146.             Przedmiot subject4 = new Przedmiot("Rachunek prawodpodobieństwa i statystyka", "Matematyka", "Matematyka Finansowa", 1, 30);
  147.             student1.DodajOcene(subject1, 4.5d, "03.02.2020");
  148.             student1.DodajOcene(subject1, 3.5d, "13.03.2020");
  149.             student2.DodajOcene(subject3, 5.0d, "02.01.2020");
  150.             student2.DodajOcene(subject4, 3.0d, "07.09.2020");
  151.             student3.DodajOcene(subject2, 5.0d, "03.02.2020");
  152.             student3.DodajOcene(subject1, 3.0d, "05.07.2020");
  153.             Wykladowca wyk1 = new Wykladowca("Dominik", "Jachaś", "12.12.1978", "dr inż.", "Adiunkt");
  154.             Wykladowca wyk2 = new Wykladowca("Bogdan", "Boner", "12.10.1960", "Prof. dr hab. inż.", "Profesor");
  155.             Wykladowca wyk3 = new Wykladowca("Marcin", "Łopian", "12.02.1968", "dr inż.", "Adiunkt");
  156.             Wykladowca wyk4 = new Wykladowca("Tadeusz", "Sum", "12.01.1969", "dr hab. inż.", "Profesor");
  157.             Jednostka jednostka1 = new Jednostka("Instytut Informatyki Teoretycznej i Stosowanej", "Częstochowa");
  158.             Jednostka jednostka2 = new Jednostka("Instytut Inteligentnych Systemów Informatycznych", "Częstochowa");
  159.             jednostka1.DodajWykladowce(wyk1);
  160.             jednostka1.DodajWykladowce(wyk2);
  161.             jednostka2.DodajWykladowce(wyk3);
  162.             jednostka2.DodajWykladowce(wyk4);
  163.             Wykladowca w = new Wykladowca("Tytus", "Bomba", "12.01.1955", "Prof. dr hab.inż.", "Profesor");
  164.             Wydzial wydz = new Wydzial();
  165.             wydz.DodajJednostke("Wydział Inżynierii Mechanicznej i Informatyki", "ul. Dąbrowskiego 44, Częstochowa");
  166.             wydz.DodajJednostke("Wydział Zarządzania", "ul. Armii Krajowej 33");
  167.             wydz.DodajWykladowce(w, "Wydział Inżynierii Mechanicznej i Informatyki");
  168.             wydz.DodajPrzedmiot(subject1);
  169.             wydz.DodajPrzedmiot(subject2);
  170.             wydz.DodajPrzedmiot(subject3);
  171.             wydz.DodajPrzedmiot(subject4);
  172.             wydz.DodajStudenta(student1);
  173.             wydz.DodajStudenta(student2);
  174.             wydz.DodajStudenta((Student)student3);
  175.  
  176.  
  177.             Console.WriteLine("-----------------------------------------------------------------------");
  178.             wydz.InfoStudenci(true);
  179.             Console.WriteLine("-----------------------------------------------------------------------");
  180.             wydz.DodajOcene(765123, "Programowanie obiektowe", 3.0, "06.04.2020",subject1);
  181.             wydz.InfoStudenci(true);
  182.             Console.WriteLine("-----------------------------------------------------------------------");
  183.             wydz.UsunStudenta(123123);
  184.             wydz.InfoJednostki(true);
  185.             wydz.PrzeniesWykladowce(wyk2, "Wydział Inżynierii Mechanicznej i Informatyki", "Wydział Zarządzania");
  186.             Console.WriteLine("-----------------------------------------------------------------------");
  187.             wydz.InfoStudenci(true);
  188.             Console.WriteLine("-----------------------------------------------------------------------");
  189.             wydz.InfoPrzedmioty();
  190.             Console.WriteLine("-----------------------------------------------------------------------");
  191.             wydz.InfoJednostki(true);
  192.             Console.WriteLine("-----------------------------------------------------------------------");
  193.             Console.ReadKey();
  194.         }
  195.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement