Guest User

Untitled

a guest
Jan 24th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Biblioteka
  7. {
  8.     class Wykonawcy {
  9.         private string imie_nazwisko;
  10.         public Wykonawcy(string arg)
  11.         {
  12.             imie_nazwisko = arg;
  13.         }
  14.     }
  15.     class Utwor {
  16.         private string tytul;
  17.         private int dlugosc;
  18.         private string wykonawca;
  19.  
  20.         public Utwor(string tyt, int dlug, string wyk)
  21.         {
  22.             tytul = tyt;
  23.             dlugosc = dlug;
  24.             wykonawca = wyk;
  25.         }
  26.         public string Wyswietl()
  27.         {
  28.             return tytul + ", " + dlugosc + ", " + wykonawca;
  29.         }
  30.         public int PodajDlugosc()
  31.         {
  32.             return dlugosc;
  33.         }
  34.     }
  35.     class Plyta
  36.     {
  37.         private string tytul;
  38.         private string typ;
  39.      
  40.         private List<Utwor> utwory = new List<Utwor>{};
  41.  
  42.         public Plyta(string arg1, string arg2)
  43.         {
  44.             tytul = arg1;
  45.             typ = arg2;
  46.          
  47.         }
  48.  
  49.         public override string ToString()
  50.         {
  51.             return tytul;
  52.         }
  53.  
  54.         public void DodajUtwor(Utwor utwor) {
  55.             utwory.Add(utwor);
  56.         }
  57.         public int PodajCzas()
  58.         {
  59.             int suma = 0;
  60.             foreach (var item in utwory)
  61.             {
  62.                 suma += item.PodajDlugosc();
  63.             }
  64.             return suma;
  65.         }
  66.         public void PokazUtwory()
  67.         {
  68.             Console.WriteLine("     Tytul: " + tytul);
  69.             Console.WriteLine("     Czas trwania: " + this.PodajCzas()/60 + " minuty");
  70.             Console.WriteLine("     Typ: " + typ);
  71.             Console.WriteLine("     Utwory (nr, tytuł, czas trwania, wykonawca)\n");
  72.  
  73.             if (utwory.Count == 0)
  74.             {
  75.                 Console.WriteLine("     Brak utworów na tej płycie");
  76.             }
  77.  
  78.             int licznik = 1;
  79.             foreach (var item in utwory)
  80.             {
  81.                 Console.WriteLine("          "+licznik + ". "+item.Wyswietl());
  82.                 licznik++;
  83.             }
  84.         }
  85.     }
  86.     class Funkcje
  87.     {
  88.         public static bool Sprawdz(string arg) {
  89.             if (arg == "0")
  90.                 return false;
  91.             else
  92.                 return true;
  93.         }
  94.         public static bool SprawdzInt(int arg)
  95.         {
  96.             if (arg == 0)
  97.                 return false;
  98.             else
  99.                 return true;
  100.         }
  101.     }
  102.    
  103. }
Add Comment
Please, Sign In to add comment