ProgaOra/20231215/ConsoleApp1/Program.cs
2024-01-19 15:06:27 +01:00

93 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Tanulo
{
public string nev;
public List<int> matek = new List<int>();
public List<int> tortenelem = new List<int>();
public List<int> angol = new List<int>();
public List<int> tesi = new List<int>();
public List<int> nyelvtan = new List<int>();
public string Nev
{
get { return this.nev; }
set { this.nev = value;}
}
public double Atlag(List<int> l)
{
return l.Average();
}
public void Jegyek(List<int> l)
{
Console.WriteLine("A jegyeid az adott tantárgyból:");
foreach (int i in l)
{
Console.WriteLine(i);
}
Console.WriteLine("");
}
public void JegyAdd(string tantargy, int j)
{
if (tantargy == "matek")
{
matek.Add(j);
}
else if (tantargy == "tori")
{
tortenelem.Add(j);
}
else if (tantargy == "tesi")
{
tesi.Add(j);
}
else if (tantargy == "angol")
{
angol.Add(j);
}
else if (tantargy == "nyelvtan")
{
nyelvtan.Add(j);
}
}
public Tanulo(string n)
{
Nev = n;
}
}
class Program
{
static void Main(string[] args)
{
Tanulo digi = new Tanulo("Szabó Márton");
digi.JegyAdd("matek", 5);
digi.JegyAdd("matek", 5);
digi.JegyAdd("matek", 5);
digi.JegyAdd("matek", 5);
digi.JegyAdd("nyelvtan", 5);
digi.JegyAdd("nyelvtan", 4);
Console.WriteLine($"A tantárgy átlaga: {digi.Atlag(digi.nyelvtan)}");
digi.Jegyek(digi.matek);
Console.WriteLine(digi.Nev);
Tanulo asd = new Tanulo("Asd");
Console.WriteLine(asd.Nev);
asd.JegyAdd("tori", 3);
Console.WriteLine($"A tantárgy átlaga: {asd.Atlag(asd.tortenelem)}");
asd.Jegyek(asd.tortenelem);
}
}
}