75 lines
1.5 KiB
C#
75 lines
1.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
// Szabó Márton 12/b
|
|||
|
// A csoport
|
|||
|
|
|||
|
namespace ConsoleApp1
|
|||
|
{
|
|||
|
class Diak
|
|||
|
{
|
|||
|
private string nev;
|
|||
|
private int eletkor;
|
|||
|
|
|||
|
public string Nev
|
|||
|
{
|
|||
|
get { return this.nev; }
|
|||
|
set { this.nev = value;}
|
|||
|
}
|
|||
|
|
|||
|
public int Eletkor
|
|||
|
{
|
|||
|
get { return this.eletkor; }
|
|||
|
set { this.eletkor = value;}
|
|||
|
}
|
|||
|
|
|||
|
public Diak(string diaknev, int diakkor)
|
|||
|
{
|
|||
|
Nev = diaknev;
|
|||
|
Eletkor = diakkor;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
class Osztaly
|
|||
|
{
|
|||
|
public string osztalynev;
|
|||
|
public List<Diak> tanulok = new List<Diak>();
|
|||
|
|
|||
|
public Osztaly(){}
|
|||
|
|
|||
|
public void Diakhozzaad(Diak tanulo)
|
|||
|
{
|
|||
|
this.tanulok.Add(tanulo);
|
|||
|
}
|
|||
|
|
|||
|
public void Diakadatok()
|
|||
|
{
|
|||
|
Console.WriteLine(this.osztalynev);
|
|||
|
Console.WriteLine();
|
|||
|
foreach (Diak tanulo in tanulok)
|
|||
|
{
|
|||
|
Console.WriteLine($"{tanulo.Nev}, kor:{tanulo.Eletkor}");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
class Program
|
|||
|
{
|
|||
|
static void Main(string[] args)
|
|||
|
{
|
|||
|
Osztaly osztaly = new Osztaly { osztalynev = "12/B"};
|
|||
|
Diak diak1 = new Diak("Szabó Márton", 18);
|
|||
|
Diak diak2 = new Diak("Medve Gergő", 18);
|
|||
|
|
|||
|
osztaly.Diakhozzaad(diak1);
|
|||
|
osztaly.Diakhozzaad(diak2);
|
|||
|
|
|||
|
osztaly.Diakadatok();
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|