add some corrections to "notenbewertung"
This commit is contained in:
parent
df64e1841d
commit
614362e61a
|
@ -45,6 +45,9 @@
|
||||||
<Compile Include="Mediator\Client.cs" />
|
<Compile Include="Mediator\Client.cs" />
|
||||||
<Compile Include="Mediator\DevTeam.cs" />
|
<Compile Include="Mediator\DevTeam.cs" />
|
||||||
<Compile Include="Mediator\Mediator.cs" />
|
<Compile Include="Mediator\Mediator.cs" />
|
||||||
|
<Compile Include="Observer\Abonennt.cs" />
|
||||||
|
<Compile Include="Observer\Observer.cs" />
|
||||||
|
<Compile Include="Observer\Verlag.cs" />
|
||||||
<Compile Include="Proxy\Driver.cs" />
|
<Compile Include="Proxy\Driver.cs" />
|
||||||
<Compile Include="Singleton\EagerSingleton.cs" />
|
<Compile Include="Singleton\EagerSingleton.cs" />
|
||||||
<Compile Include="Proxy\ICar.cs" />
|
<Compile Include="Proxy\ICar.cs" />
|
||||||
|
|
|
@ -8,10 +8,9 @@ namespace notenbewertung
|
||||||
{
|
{
|
||||||
class Dozent : Person
|
class Dozent : Person
|
||||||
{
|
{
|
||||||
public Dozent(string _vorname, string _name)
|
public Dozent(string _vorname, string _name) : base(_vorname, _name)
|
||||||
{
|
{
|
||||||
this.Vorname = _vorname;
|
|
||||||
this.Name = _name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,15 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace notenbewertung
|
namespace notenbewertung
|
||||||
{
|
{
|
||||||
class Klasse : List<Person>
|
class Klasse
|
||||||
{
|
{
|
||||||
public string Klassenbezeichnung { get; set; }
|
public string Klassenbezeichnung { get; set; }
|
||||||
|
public List<Person> Personen { get; set; }
|
||||||
|
|
||||||
public Klasse(string _Klassenbezeichnung)
|
public Klasse(string _Klassenbezeichnung)
|
||||||
{
|
{
|
||||||
this.Klassenbezeichnung = _Klassenbezeichnung;
|
this.Klassenbezeichnung = _Klassenbezeichnung;
|
||||||
|
this.Personen = new List<Person>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ namespace notenbewertung
|
||||||
{
|
{
|
||||||
public string Vorname { get; set; }
|
public string Vorname { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public Person(string _vorname, string _name)
|
||||||
|
{
|
||||||
|
this.Vorname = _vorname;
|
||||||
|
this.Name = _name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,34 +37,35 @@ namespace notenbewertung
|
||||||
max.noten.Add(exam6);
|
max.noten.Add(exam6);
|
||||||
|
|
||||||
// each class needs a school
|
// each class needs a school
|
||||||
ibz.Add(ti5);
|
ibz.Klassen.Add(ti5);
|
||||||
ibz.Add(ti3);
|
ibz.Klassen.Add(ti3);
|
||||||
|
|
||||||
// many people belong to a class
|
// many people belong to a class
|
||||||
ti5.Add(thomas);
|
ti5.Personen.Add(thomas);
|
||||||
ti5.Add(andreas);
|
ti5.Personen.Add(andreas);
|
||||||
|
|
||||||
ti3.Add(max);
|
ti3.Personen.Add(max);
|
||||||
ti3.Add(herren);
|
ti3.Personen.Add(herren);
|
||||||
|
|
||||||
Console.WriteLine(ibz.Standort);
|
Console.WriteLine(ibz.Standort);
|
||||||
Console.WriteLine("------");
|
Console.WriteLine("------");
|
||||||
foreach (var klasse in ibz)
|
foreach (Klasse klasse in ibz.Klassen)
|
||||||
{
|
{
|
||||||
Console.WriteLine(klasse.Klassenbezeichnung);
|
Console.WriteLine(klasse.Klassenbezeichnung);
|
||||||
Console.WriteLine("------");
|
Console.WriteLine("------");
|
||||||
foreach (var person in klasse)
|
foreach (Person person in klasse.Personen)
|
||||||
{
|
{
|
||||||
Console.WriteLine(person.Name + " " + person.Vorname);
|
Console.WriteLine(person.Name + " " + person.Vorname);
|
||||||
|
if (person is Student)
|
||||||
|
{
|
||||||
|
Student s = (Student)person;
|
||||||
|
Console.WriteLine("Notendurchschnitt: ");
|
||||||
|
s.GetNotenDurchSchnitt();
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
}
|
}
|
||||||
Console.WriteLine("------");
|
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();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,14 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace notenbewertung
|
namespace notenbewertung
|
||||||
{
|
{
|
||||||
class Schule : List<Klasse>
|
class Schule
|
||||||
{
|
{
|
||||||
public string Standort { get; set; }
|
public string Standort { get; set; }
|
||||||
|
public List<Klasse> Klassen { get; set; }
|
||||||
public Schule(string _standort)
|
public Schule(string _standort)
|
||||||
{
|
{
|
||||||
this.Standort = _standort;
|
this.Standort = _standort;
|
||||||
|
this.Klassen = new List<Klasse>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,27 +9,22 @@ namespace notenbewertung
|
||||||
class Student : Person
|
class Student : Person
|
||||||
{
|
{
|
||||||
public List<Testresultat> noten = new List<Testresultat>();
|
public List<Testresultat> noten = new List<Testresultat>();
|
||||||
double summe;
|
public Student(string _vorname, string _name) : base(_vorname, _name)
|
||||||
public Student(string _vorname, string _name)
|
|
||||||
{
|
{
|
||||||
this.Vorname = _vorname;
|
|
||||||
this.Name = _name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetNotenDurchSchnitt()
|
public void GetNotenDurchSchnitt()
|
||||||
{
|
{
|
||||||
if (noten.Count > 0)
|
if (noten.Count > 0)
|
||||||
{
|
{
|
||||||
int counter = 0;
|
double result = Math.Round(this.noten.Average(n => n.Note), 2);
|
||||||
this.summe = 0;
|
Console.WriteLine(result);
|
||||||
foreach (var i in noten)
|
}
|
||||||
{
|
else
|
||||||
this.summe += i.Note;
|
{
|
||||||
counter++;
|
Console.WriteLine("Der Student hat noch keine N0ten.");
|
||||||
}
|
|
||||||
return Math.Round(this.summe / counter,2);
|
|
||||||
}
|
}
|
||||||
return this.summe;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue