Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication7
- {
- class Osoba
- {
- public int rok_urodzenia;
- public string plec;
- public Osoba(int rok_urodzenia, string plec)
- {
- this.rok_urodzenia = rok_urodzenia;
- this.plec = plec;
- }
- public Osoba() { }
- }
- class Uczen : Osoba
- {
- public double srednia_ocen;
- public Uczen(double srednia_ocen, int rok_urodzenia, string plec)
- : base(rok_urodzenia, plec)
- {
- this.srednia_ocen = srednia_ocen;
- }
- public Uczen() { }
- }
- class Ewidencja
- {
- public List<Osoba> l;
- public Ewidencja()
- {
- l = new List<Osoba>();
- l.Clear();
- }
- public void dopisz(Osoba s)
- {
- l.Add(s);
- }
- public bool sprawdz()
- {
- foreach (Osoba o in l)
- {
- if (o is Osoba)
- if ((o as Osoba).rok_urodzenia == 1990)
- return true;
- }
- return false;
- }
- public int ile_m(Uczen s)
- {
- int ile = 0;
- foreach (Uczen u in l)
- {
- if (u is Uczen)
- if ((u as Uczen).srednia_ocen >= 4)
- ile++;
- }
- return ile;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Ewidencja EW = new Ewidencja();
- Uczen u1 = new Uczen(3.9, 1990, "Kobieta");
- Uczen u2 = new Uczen(4.3, 1990, "Kobieta");
- Uczen u3 = new Uczen(4.5, 1990, "Kobieta");
- EW.dopisz(u1);
- EW.dopisz(u2);
- EW.dopisz(u3);
- Console.WriteLine(EW.ile_m(s));
- //Console.Write(EW.sprawdz());
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement