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 Zadania
- {
- class Program
- {
- static void Main(string[] args)
- {
- object[] osoby = new object[50];
- for (int i = 0; i < 50; i++)
- {
- if (i % 2 == 0)
- {
- osoby[i] = new Osoba("Daniel", 20);
- }
- else if (i % 3 == 0)
- {
- osoby[i] = new Osoba("Karol", 19);
- }
- else
- osoby[i] = new Osoba("Konrad", 61);
- }
- Console.WriteLine($"W grupie mamy {Osoba.iloscDan} Danieli, {Osoba.iloscKar} Karoli i {Osoba.iloscKon} Konradów.");
- Console.ReadKey();
- }
- internal class Osoba
- {
- string imie;
- int wiek;
- public static int iloscDan;
- public static int iloscKon;
- public static int iloscKar;
- public Osoba(string imie, int wiek)
- {
- this.imie = imie;
- this.wiek = wiek;
- if (this.imie == "Daniel")
- {
- iloscDan++;
- }
- else if (this.imie == "Konrad")
- {
- iloscKon++;
- }
- else
- {
- iloscKar++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement