Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication7
  8. {
  9.     class Osoba
  10.     {
  11.         public int rok_urodzenia;
  12.         public string plec;
  13.  
  14.         public Osoba(int rok_urodzenia, string plec)
  15.         {
  16.             this.rok_urodzenia = rok_urodzenia;
  17.             this.plec = plec;
  18.         }
  19.  
  20.         public Osoba() { }
  21.     }
  22.  
  23.     class Uczen : Osoba
  24.     {
  25.         public double srednia_ocen;
  26.  
  27.         public Uczen(double srednia_ocen, int rok_urodzenia, string plec)
  28.             : base(rok_urodzenia, plec)
  29.         {
  30.             this.srednia_ocen = srednia_ocen;
  31.         }
  32.  
  33.         public Uczen() { }
  34.     }
  35.  
  36.  
  37.     class Ewidencja
  38.     {
  39.         public List<Osoba> l;
  40.         public Ewidencja()
  41.         {
  42.             l = new List<Osoba>();
  43.             l.Clear();
  44.         }
  45.         public void dopisz(Osoba s)
  46.         {
  47.             l.Add(s);
  48.         }
  49.         public bool sprawdz()
  50.         {
  51.             foreach (Osoba o in l)
  52.             {
  53.                 if (o is Osoba)
  54.                     if ((o as Osoba).rok_urodzenia == 1990)
  55.                         return true;
  56.             }
  57.             return false;
  58.         }
  59.  
  60.         public int ile_m(Uczen s)
  61.         {
  62.             int ile = 0;
  63.             foreach (Uczen u in l)
  64.             {
  65.                 if (u is Uczen)
  66.                     if ((u as Uczen).srednia_ocen >= 4)
  67.                         ile++;
  68.             }
  69.             return ile;
  70.         }
  71.     }
  72.  
  73.     class Program
  74.     {
  75.         static void Main(string[] args)
  76.         {
  77.             Ewidencja EW = new Ewidencja();
  78.             Uczen u1 = new Uczen(3.9, 1990, "Kobieta");
  79.             Uczen u2 = new Uczen(4.3, 1990, "Kobieta");
  80.             Uczen u3 = new Uczen(4.5, 1990, "Kobieta");
  81.  
  82.             EW.dopisz(u1);
  83.             EW.dopisz(u2);
  84.             EW.dopisz(u3);
  85.  
  86.             Console.WriteLine(EW.ile_m(s));
  87.             //Console.Write(EW.sprawdz());
  88.             Console.ReadLine();
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement