finalize the "notenbewertung" excercise
This commit is contained in:
parent
b735923ebd
commit
dd55ff4d5d
|
@ -8,7 +8,7 @@ namespace notenbewertung
|
|||
{
|
||||
class Dozent : Person
|
||||
{
|
||||
public Dozent(string _vorname, string _name)
|
||||
public Dozent(string _vorname, string _name)
|
||||
{
|
||||
this.Vorname = _vorname;
|
||||
this.Name = _name;
|
||||
|
|
|
@ -6,9 +6,8 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace notenbewertung
|
||||
{
|
||||
class Klasse
|
||||
class Klasse : List<Person>
|
||||
{
|
||||
List<Person> personen = new List<Person>();
|
||||
public string Klassenbezeichnung { get; set; }
|
||||
|
||||
public Klasse(string _Klassenbezeichnung)
|
||||
|
|
|
@ -10,17 +10,61 @@ namespace notenbewertung
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// create some objects
|
||||
Schule ibz = new Schule("Aarau");
|
||||
Klasse ti5 = new Klasse("TI5");
|
||||
Klasse ti3 = new Klasse("TI3");
|
||||
Student andreas = new Student("Andreas", "Zweili");
|
||||
Student max = new Student("Max", "Muster");
|
||||
Dozent thomas = new Dozent("Thomas", "Steiner");
|
||||
Dozent herren = new Dozent("Herren", "Christian");
|
||||
Testresultat exam1 = new Testresultat(5.1);
|
||||
Testresultat exam2 = new Testresultat(5.2);
|
||||
Testresultat exam3 = new Testresultat(5.3);
|
||||
Testresultat exam4 = new Testresultat(4.3);
|
||||
Testresultat exam5 = new Testresultat(4.4);
|
||||
Testresultat exam6 = new Testresultat(5.3);
|
||||
|
||||
// add connections between objects
|
||||
|
||||
//give a student some exam results
|
||||
andreas.noten.Add(exam1);
|
||||
andreas.noten.Add(exam2);
|
||||
andreas.noten.Add(exam3);
|
||||
|
||||
max.noten.Add(exam4);
|
||||
max.noten.Add(exam5);
|
||||
max.noten.Add(exam6);
|
||||
|
||||
// each class needs a school
|
||||
ibz.Add(ti5);
|
||||
ibz.Add(ti3);
|
||||
|
||||
// many people belong to a class
|
||||
ti5.Add(thomas);
|
||||
ti5.Add(andreas);
|
||||
|
||||
ti3.Add(max);
|
||||
ti3.Add(herren);
|
||||
|
||||
Console.WriteLine(ibz.Standort);
|
||||
Console.WriteLine("------");
|
||||
foreach (var klasse in ibz)
|
||||
{
|
||||
Console.WriteLine(klasse.Klassenbezeichnung);
|
||||
Console.WriteLine("------");
|
||||
foreach (var person in klasse)
|
||||
{
|
||||
Console.WriteLine(person.Name + " " + person.Vorname);
|
||||
}
|
||||
Console.WriteLine("------");
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine(andreas.Name + " " + andreas.Vorname);
|
||||
Console.WriteLine(andreas.GetNotenDurchSchnitt().ToString());
|
||||
Console.WriteLine(max.Name + " " + max.Vorname);
|
||||
Console.WriteLine(max.GetNotenDurchSchnitt().ToString());
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,9 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace notenbewertung
|
||||
{
|
||||
class Schule
|
||||
class Schule : List<Klasse>
|
||||
{
|
||||
string Standort { get; set; }
|
||||
List<Klasse> klassen = new List<Klasse>();
|
||||
public string Standort { get; set; }
|
||||
public Schule(string _standort)
|
||||
{
|
||||
this.Standort = _standort;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace notenbewertung
|
|||
this.summe += i.Note;
|
||||
counter++;
|
||||
}
|
||||
return this.summe / counter;
|
||||
return Math.Round(this.summe / counter,2);
|
||||
}
|
||||
return this.summe;
|
||||
}
|
||||
|
|
Reference in New Issue