Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Klassen:
- =============================================================================================
- abstract class Certificate (wenn bei Umlet Diagramm Klassenname kursiv geschrieben ist dann ist die Klasse abstract)
- private DateTime date;
- private List<Subject> subjectList;
- public void addSubject(Subject subject) { subjectList.Add(subject); }
- public double calculateAverage() {
- double sum = 0;
- foreach(Subject subject in subjectList) {
- sum += subject.getMark();
- }
- if (subjectList.Count == 0) return 0;
- return sum / subjectList.Count;
- }
- public void AusgabeSubjectList() {
- subjectList.ForEach(Console.WriteLine);
- }
- public abstract void printCertificate();
- =============================================================================================
- class CollegeCertificate : Certificate
- public CollegeCertificate() : base(parameter für Constructor von Unterklasse Certificate) {
- }
- public void insertData() {
- Console.Write($"Schüler: {pupilName}");
- string eingabe = "";
- do {
- Subject subject = new Subject();
- Console.Write("Name des Faches: ");
- eingabe = Console.ReadLine();
- subject.SetName(eingabe);
- Console.Write("Note in diesem Fach: ");
- eingabe = Console.ReadLine();
- subject.SetMark(Convert.ToDouble(eingabe));
- Console.Write("Neues Fach hinzufügen? (ja/nein): ");
- eingabe = Console.ReadLine();
- } while(eingabe.Equals("ja"));
- }
- public override void printCertificate() {
- Console.Write(name);
- Console.Write(abschluss);
- Console.Write(name der schule);
- Console.Write(Datum);
- AusgabeSubjectlist();
- Console.Write(CalcAverage());
- Console.Write(remarks);
- }
- =============================================================================================
- class Subject
- private string name;
- private double mark;
- public override string ToString() {
- return $"Fach: {name} Note: {mark}";
- }
- =============================================================================================
- Main() {
- CollegeCertificate mycertificate = new CollegeCertificate("Abschlusszeugnis", "GDS blub", "SChülername", ...)
- mycertificate.insertData();
- Console.Clear();
- mycertificate.printCertificate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement