-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ergebnis.cs
70 lines (56 loc) · 1.79 KB
/
Ergebnis.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Daten
{
class Ergebis
{
private Schüler _schüler;
public Schüler schüler
{
get { return _schüler; }
}
private Fach _fach;
public Fach fach
{
get { return _fach; }
}
private Schulhalbjahr _schulhalbjahr;
public Schulhalbjahr schulhalbjahr
{
get { return _schulhalbjahr; }
}
private int _note;
public int note
{
get { return _note; }
}
public Ergebis(Schüler schüler, Fach fach, Schulhalbjahr schulhalbjahr, int note)
{
if (note < 1 || note > 6)
throw new Exception("Ungültige Note");
if (schüler == null || fach == null || schulhalbjahr == null)
throw new Exception("Es Fehlt mindestens eine Angabe des Ergebisses");
this._schüler = schüler;
this._fach = fach;
this._schulhalbjahr = schulhalbjahr;
this._note = note;
}
public override bool Equals(object obj)
{
Ergebis ergebnis = obj as Ergebis;
return ergebnis != null && this._schüler.Equals(ergebnis._schüler) && this._fach.Equals(ergebnis._fach)
&& this._schulhalbjahr.Equals(ergebnis._schulhalbjahr) && this._note.Equals(ergebnis._note);
}
public override int GetHashCode()
{
return _schüler.GetHashCode() ^ _fach.GetHashCode() ^ _schulhalbjahr.GetHashCode() ^ _note.GetHashCode();
}
public override string ToString()
{
return string.Format("Schüler: {0}; Fach: {1}; Schulhalbjahr: {2}; Note: {3}", schüler, fach, schulhalbjahr, note);
}
}
}