From 33e49f846c2646814e0ff6bc363e2347d1359a8a Mon Sep 17 00:00:00 2001 From: Baerspektivo Date: Thu, 23 Mar 2023 12:24:40 +0100 Subject: [PATCH] =?UTF-8?q?Projektdateien=20hinzuf=C3=BCgen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeispielAbhängigkeiten.csproj | 10 ++ BeispielAbhängigkeiten/Book.cs | 21 +++ BeispielAbhängigkeiten/Program.cs | 17 +++ BeispielAbhängigkeiten/Student.cs | 26 ++++ .../BeispielAggregation.csproj | 10 ++ BeispielAggregation/Class.cs | 44 ++++++ BeispielAggregation/Program.cs | 17 +++ BeispielAggregation/Student.cs | 29 ++++ .../BeispielAssoziation.csproj | 10 ++ BeispielAssoziation/Class.cs | 29 ++++ BeispielAssoziation/Program.cs | 22 +++ BeispielAssoziation/Room.cs | 28 ++++ .../BeispielConstructur.csproj | 10 ++ BeispielConstructur/Program.cs | 31 ++++ .../BeispielKomposition.csproj | 10 ++ BeispielKomposition/Building.cs | 33 +++++ BeispielKomposition/Floor.cs | 17 +++ BeispielKomposition/Program.cs | 12 ++ BeispielProperties/BeispielProperties.csproj | 10 ++ BeispielProperties/Program.cs | 61 ++++++++ BeispielStatic/BeispielStatic.csproj | 10 ++ BeispielStatic/Program.cs | 31 ++++ BeispielThis/BeispielThis.csproj | 10 ++ BeispielThis/Program.cs | 36 +++++ BeispielVererbung/BeispielVererbung.csproj | 10 ++ BeispielVererbung/Program.cs | 59 ++++++++ BeispielÜberschreiben/Auto.cs | 21 +++ BeispielÜberschreiben/Ballon.cs | 20 +++ .../BeispielÜberschreiben.csproj | 10 ++ BeispielÜberschreiben/Fahrzeug.cs | 26 ++++ BeispielÜberschreiben/Program.cs | 28 ++++ BeispielÜberschreiben/Schiff.cs | 20 +++ Overload/Overload.csproj | 10 ++ Overload/Program.cs | 23 +++ Papier/Papier.csproj | 10 ++ Papier/Program.cs | 28 ++++ Papier2/Papier2.csproj | 10 ++ Papier2/Program.cs | 44 ++++++ Persona2/Persona2.csproj | 10 ++ Persona2/Program.cs | 64 +++++++++ SammelmappeFuerOop.sln | 133 ++++++++++++++++++ SammelmappeFuerOop/Program.cs | 49 +++++++ SammelmappeFuerOop/SammelmappeFuerOop.csproj | 10 ++ Spielerkader/Program.cs | 43 ++++++ Spielerkader/Spielerkader.csproj | 10 ++ Spielerkarder2/Program.cs | 88 ++++++++++++ Spielerkarder2/Spielerkarder2.csproj | 10 ++ Sweatshirt/Program.cs | 73 ++++++++++ Sweatshirt/Sweatshirt.csproj | 10 ++ Sweatshirt2/Program.cs | 81 +++++++++++ Sweatshirt2/Sweatshirt2.csproj | 10 ++ 51 files changed, 1444 insertions(+) create mode 100644 BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj create mode 100644 BeispielAbhängigkeiten/Book.cs create mode 100644 BeispielAbhängigkeiten/Program.cs create mode 100644 BeispielAbhängigkeiten/Student.cs create mode 100644 BeispielAggregation/BeispielAggregation.csproj create mode 100644 BeispielAggregation/Class.cs create mode 100644 BeispielAggregation/Program.cs create mode 100644 BeispielAggregation/Student.cs create mode 100644 BeispielAssoziation/BeispielAssoziation.csproj create mode 100644 BeispielAssoziation/Class.cs create mode 100644 BeispielAssoziation/Program.cs create mode 100644 BeispielAssoziation/Room.cs create mode 100644 BeispielConstructur/BeispielConstructur.csproj create mode 100644 BeispielConstructur/Program.cs create mode 100644 BeispielKomposition/BeispielKomposition.csproj create mode 100644 BeispielKomposition/Building.cs create mode 100644 BeispielKomposition/Floor.cs create mode 100644 BeispielKomposition/Program.cs create mode 100644 BeispielProperties/BeispielProperties.csproj create mode 100644 BeispielProperties/Program.cs create mode 100644 BeispielStatic/BeispielStatic.csproj create mode 100644 BeispielStatic/Program.cs create mode 100644 BeispielThis/BeispielThis.csproj create mode 100644 BeispielThis/Program.cs create mode 100644 BeispielVererbung/BeispielVererbung.csproj create mode 100644 BeispielVererbung/Program.cs create mode 100644 BeispielÜberschreiben/Auto.cs create mode 100644 BeispielÜberschreiben/Ballon.cs create mode 100644 BeispielÜberschreiben/BeispielÜberschreiben.csproj create mode 100644 BeispielÜberschreiben/Fahrzeug.cs create mode 100644 BeispielÜberschreiben/Program.cs create mode 100644 BeispielÜberschreiben/Schiff.cs create mode 100644 Overload/Overload.csproj create mode 100644 Overload/Program.cs create mode 100644 Papier/Papier.csproj create mode 100644 Papier/Program.cs create mode 100644 Papier2/Papier2.csproj create mode 100644 Papier2/Program.cs create mode 100644 Persona2/Persona2.csproj create mode 100644 Persona2/Program.cs create mode 100644 SammelmappeFuerOop.sln create mode 100644 SammelmappeFuerOop/Program.cs create mode 100644 SammelmappeFuerOop/SammelmappeFuerOop.csproj create mode 100644 Spielerkader/Program.cs create mode 100644 Spielerkader/Spielerkader.csproj create mode 100644 Spielerkarder2/Program.cs create mode 100644 Spielerkarder2/Spielerkarder2.csproj create mode 100644 Sweatshirt/Program.cs create mode 100644 Sweatshirt/Sweatshirt.csproj create mode 100644 Sweatshirt2/Program.cs create mode 100644 Sweatshirt2/Sweatshirt2.csproj diff --git a/BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj b/BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielAbhängigkeiten/Book.cs b/BeispielAbhängigkeiten/Book.cs new file mode 100644 index 0000000..43d743c --- /dev/null +++ b/BeispielAbhängigkeiten/Book.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAbhängigkeiten +{ + internal class Book + { + private string content; + private string title; + + public Book(string title, string content) + { + this.title = title; + this.content = content; + } + public string GetInfos() { return this.content; } + } +} diff --git a/BeispielAbhängigkeiten/Program.cs b/BeispielAbhängigkeiten/Program.cs new file mode 100644 index 0000000..22349c3 --- /dev/null +++ b/BeispielAbhängigkeiten/Program.cs @@ -0,0 +1,17 @@ +namespace BeispielAbhängigkeiten +{ + internal class Program + { + static void Main(string[] args) + { + Student udo = new Student("Udo"); + Book b1 = new Book("SQL", "Alles über SQL und noch viel mehr ..."); + Book b2 = new Book("OOP", "Alles über OOP und noch viel mehr ..."); + Book b3 = new Book("TCP", "Alles über TCO und noch viel menr ..."); + + udo.ReadBook(b1); + udo.ReadBook(b2); + udo.ReadBook(b3); + } + } +} \ No newline at end of file diff --git a/BeispielAbhängigkeiten/Student.cs b/BeispielAbhängigkeiten/Student.cs new file mode 100644 index 0000000..81f1383 --- /dev/null +++ b/BeispielAbhängigkeiten/Student.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAbhängigkeiten +{ + internal class Student + { + private string name; + private string wissen; + public Student(string name) + { + this.name = name; + } + public void ReadBook(Book book) + { + string infos = book.GetInfos(); + wissen = wissen + "\n" + infos; + Console.WriteLine("Ich habe gerade gelesen: "); + Console.WriteLine(infos); + } + + } +} diff --git a/BeispielAggregation/BeispielAggregation.csproj b/BeispielAggregation/BeispielAggregation.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielAggregation/BeispielAggregation.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielAggregation/Class.cs b/BeispielAggregation/Class.cs new file mode 100644 index 0000000..f020932 --- /dev/null +++ b/BeispielAggregation/Class.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAggregation +{ + internal class Class + { + private string name; + private Student[] students; + + public Class(string name, int cnt) + { + this.name = name; + this.students = new Student[cnt]; + } + public string GetName() { return name; } + public void AddStudent(Student student) + { + for (int i = 0; i < students.Length; i++) + { + if (students[i] == null) + { + students[i] = student; + student.SetClass(this); + break; + } + } + } + public void PrintInfos() + { + System.Console.WriteLine($"Stundenten in der Klasse {name}:"); + foreach (Student student in students) + { + if (student != null) + { + Console.WriteLine(student.GetName()); + } + } + } + } +} diff --git a/BeispielAggregation/Program.cs b/BeispielAggregation/Program.cs new file mode 100644 index 0000000..2bc1627 --- /dev/null +++ b/BeispielAggregation/Program.cs @@ -0,0 +1,17 @@ +namespace BeispielAggregation +{ + internal class Program + { + static void Main(string[] args) + { + Student franzi = new Student("Franzi"); + Student huihui = new Student("Huhui"); + + Class do7 = new Class("Do7", 5); + + do7.AddStudent(franzi); + do7.AddStudent(huihui); + do7.PrintInfos(); + } + } +} \ No newline at end of file diff --git a/BeispielAggregation/Student.cs b/BeispielAggregation/Student.cs new file mode 100644 index 0000000..27cb6f0 --- /dev/null +++ b/BeispielAggregation/Student.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAggregation +{ + internal class Student + { + private string name; + private Class _class; + + public Student(string name) + { + this.name = name; + } + public string GetName() { return this.name; } + public void SetClass(Class _class) + { + this._class = _class; + } + public void PrintInfo() + { + Console.WriteLine($"Der Student {name} ist in der klasse {_class.GetName()}"); + } + } + +} diff --git a/BeispielAssoziation/BeispielAssoziation.csproj b/BeispielAssoziation/BeispielAssoziation.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielAssoziation/BeispielAssoziation.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielAssoziation/Class.cs b/BeispielAssoziation/Class.cs new file mode 100644 index 0000000..fe5a970 --- /dev/null +++ b/BeispielAssoziation/Class.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAssoziation +{ + internal class Class + { + private Room room; + private string name; + + public Class(string name) + { + this.name = name; + } + public string GetName() { return name; } + public void SetRoom(Room room) + { + this.room = room; + this.room.SetClass(this); + } + public void PrintInfos() + { + Console.WriteLine($"Diese Klasse ist im Raum {room.Get_Name()}."); + } + } +} diff --git a/BeispielAssoziation/Program.cs b/BeispielAssoziation/Program.cs new file mode 100644 index 0000000..f79ee6f --- /dev/null +++ b/BeispielAssoziation/Program.cs @@ -0,0 +1,22 @@ +namespace BeispielAssoziation +{ + internal class Program + { + static void Main(string[] args) + { + Class oop = new Class("OOP"); + Class sql = new Class("SQL"); + + Room r1 = new Room("1"); + Room r2 = new Room("2"); + + oop.SetRoom(r1); + sql.SetRoom(r2); + + oop.PrintInfos(); + sql.PrintInfos(); + r1.PrintInfos(); + r2.PrintInfos(); + } + } +} \ No newline at end of file diff --git a/BeispielAssoziation/Room.cs b/BeispielAssoziation/Room.cs new file mode 100644 index 0000000..e3f64a6 --- /dev/null +++ b/BeispielAssoziation/Room.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielAssoziation +{ + internal class Room + { + private Class _class; + private string _name; + + public Room(string name) + { + this._name = name; + } + public string Get_Name() { return _name; } + public void SetClass(Class _class) + { + this._class = _class; + } + public void PrintInfos() + { + Console.WriteLine($"In diesem Raum ist die Klasse {_class.GetName()}."); + } + } +} diff --git a/BeispielConstructur/BeispielConstructur.csproj b/BeispielConstructur/BeispielConstructur.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielConstructur/BeispielConstructur.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielConstructur/Program.cs b/BeispielConstructur/Program.cs new file mode 100644 index 0000000..17dced4 --- /dev/null +++ b/BeispielConstructur/Program.cs @@ -0,0 +1,31 @@ +namespace BeispielConstructur +{ + internal class Program + { + static void Main(string[] args) + { + Auto a1 = new Auto("Trabant", 150); + Auto a2 = new Auto("Papamobil"); + Auto a3 = new Auto(500); + } + } + class Auto + { + private string marke; + private int ps; + public Auto(int ps) : this("Ferrari", ps) { } + public Auto(string marke) : this(marke, 50) + { + //marke = m; + //ps=50; + } + public Auto(string marke, int ps) + { + this.marke = marke; + this.ps = ps; + } + public string GetMarke() { return marke; } + public int Getps() { return ps; } + + } +} \ No newline at end of file diff --git a/BeispielKomposition/BeispielKomposition.csproj b/BeispielKomposition/BeispielKomposition.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielKomposition/BeispielKomposition.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielKomposition/Building.cs b/BeispielKomposition/Building.cs new file mode 100644 index 0000000..9281377 --- /dev/null +++ b/BeispielKomposition/Building.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielKomposition +{ + internal class Building + { + private string name; + private Floor[] floors; + + public Building(string name, int floors) + { + this.name = name; + this.floors = new Floor[floors]; + for (int i = 0; i < this.floors.Length; i++) + { + this.floors[i] = new Floor(i); + } + } + public void PrintInfos() + { + Console.WriteLine($"Gebäude {name}:"); + foreach (Floor floor in floors) + { + Console.WriteLine("Etage " + floor.GetFloorid()); + } + } + } +} diff --git a/BeispielKomposition/Floor.cs b/BeispielKomposition/Floor.cs new file mode 100644 index 0000000..9b80569 --- /dev/null +++ b/BeispielKomposition/Floor.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielKomposition +{ + internal class Floor + { + private int floorid; + + public Floor(int floorid) + { this.floorid = floorid; } + public int GetFloorid() { return floorid; } + } +} diff --git a/BeispielKomposition/Program.cs b/BeispielKomposition/Program.cs new file mode 100644 index 0000000..1348f7a --- /dev/null +++ b/BeispielKomposition/Program.cs @@ -0,0 +1,12 @@ +namespace BeispielKomposition +{ + internal class Program + { + static void Main(string[] args) + { + Building b1 = new Building ("Trump-Tower", 15); + + b1.PrintInfos(); + } + } +} \ No newline at end of file diff --git a/BeispielProperties/BeispielProperties.csproj b/BeispielProperties/BeispielProperties.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielProperties/BeispielProperties.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielProperties/Program.cs b/BeispielProperties/Program.cs new file mode 100644 index 0000000..43762b6 --- /dev/null +++ b/BeispielProperties/Program.cs @@ -0,0 +1,61 @@ +namespace BeispielProperties +{ + internal class Program + { + static void Main(string[] args) + { + //Auto a1 = new Auto(); + //a1.SetMarke("Fiat"); + //a1.Modell = "500"; + //Console.WriteLine(a1.Modell); + Quadrat q = new Quadrat(5); + Console.WriteLine(q.Breite); + Console.WriteLine(q.Umfang); + Console.WriteLine(q.Flaeche); + + } + class Auto + { + private string marke; + private string modell; + public string Modell + { + get { return modell; } + set { modell = value; } + } + //private int baujahr; + //public int Baujahr + //{ + // get { return baujahr; } + // set { baujahr = value;} + //} + public int Baujahr { get; set; } + public string GetMarke() + { return marke; } + public void SetMarke(string marke) + { this.marke = marke; } + } + class Quadrat + { + private int breite; + public int Breite + { + get { return breite; } + private set { + if (value > 0) + { breite = value;} + } + } + public int Umfang + { + get { return breite *4; } + } + public int Flaeche + { + get { return breite * breite; } + } + public Quadrat(int breite) + { Breite = breite; } + } + } +} \ No newline at end of file diff --git a/BeispielStatic/BeispielStatic.csproj b/BeispielStatic/BeispielStatic.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielStatic/BeispielStatic.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielStatic/Program.cs b/BeispielStatic/Program.cs new file mode 100644 index 0000000..85bf5f7 --- /dev/null +++ b/BeispielStatic/Program.cs @@ -0,0 +1,31 @@ +namespace BeispielStatic +{ + internal class Program + { + static void Main(string[] args) + { + Auto a1 = new Auto("Fiat", "500"); + Auto a2 = new Auto("Ford", "Fiesta"); + int anzahl = Auto.GetAnzahl(); + Console.WriteLine(anzahl); + + Console.WriteLine(a1.GetAnzahl2()); + Console.WriteLine(a2.GetAnzahl2()); + } + class Auto + { + private string marke; + private string modell; + + private static int anzahl; + public Auto(string marke, string modell) + { + this.marke = marke; + this.modell = modell; + anzahl = anzahl + 1; + } + public static int GetAnzahl() { return anzahl; } + public int GetAnzahl2() { return anzahl; } + } + } +} \ No newline at end of file diff --git a/BeispielThis/BeispielThis.csproj b/BeispielThis/BeispielThis.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielThis/BeispielThis.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielThis/Program.cs b/BeispielThis/Program.cs new file mode 100644 index 0000000..ff86cde --- /dev/null +++ b/BeispielThis/Program.cs @@ -0,0 +1,36 @@ +namespace BeispielThis +{ + internal class Program + { + static void Main(string[] args) + { + Person batman = new Person("Batman"); + Person robin = new Person("Robin"); + Console.WriteLine(batman.GetName()); + Console.WriteLine(robin.GetName()); + batman.SetPartner(robin); + //robin.SetPartner(batman); + Console.WriteLine($"Batmans Partner: {batman.GetPartner().GetName()}"); + Console.WriteLine($"Robins Partner: {robin.GetPartner().GetName()}"); + } + } + class Person + { + private string name; + private Person partner; + public Person(string name) + { + this.name = name; + } + public string GetName() { return name; } + public Person GetPartner() { return partner;} + public void SetPartner(Person partner) + { + if (this.partner == null) + { + this.partner = partner; + this.partner.SetPartner(this); + } + } + } +} \ No newline at end of file diff --git a/BeispielVererbung/BeispielVererbung.csproj b/BeispielVererbung/BeispielVererbung.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielVererbung/BeispielVererbung.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielVererbung/Program.cs b/BeispielVererbung/Program.cs new file mode 100644 index 0000000..afc568e --- /dev/null +++ b/BeispielVererbung/Program.cs @@ -0,0 +1,59 @@ +namespace BeispielVererbung +{ + internal class Program + { + static void Main(string[] args) + { + KFZ k1 = new KFZ(); + k1.RestwertBerechnen(); //Methode aus KFZ + k1.Auszahlen(); //Methode aus Versicherungsobjekt + + Immobilie i1 = new Immobilie(); + i1.RestwertBerechnen(); //Methode aus Immobilie + i1.Auszahlen(); //Methode aus Versicherungsobjekt + + Versicherungsobjekt vo1 = new Versicherungsobjekt(); + vo1.Auszahlen(); //Nur Methoden der Basisklasse sind sichtbar + } + } + class Versicherungsobjekt + { + protected double neupreis; + protected int baujahr; + protected double schadenshöhe; + + public void Auszahlen() + { + Console.WriteLine("Auszahlung"); + } + } + class KFZ : Versicherungsobjekt + { + private string? hersteller; + private string? typenschlüssel; + private int laufleistung; + + public void RestwertBerechnen() + { + Console.WriteLine("Restwert von KFZ"); + } + public void AusgabeAttribute() + { + Console.WriteLine(this.baujahr ); + } + } + class Immobilie : Versicherungsobjekt + { + private double wohnfläche; + private string? lagebewertung; + + public void RestwertBerechnen() + { + Console.WriteLine("Restwert von Immobilie"); + } + public string? GetLagebewertung() + { + return lagebewertung; + } + } +} \ No newline at end of file diff --git a/BeispielÜberschreiben/Auto.cs b/BeispielÜberschreiben/Auto.cs new file mode 100644 index 0000000..3aa28a1 --- /dev/null +++ b/BeispielÜberschreiben/Auto.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielÜberschreiben +{ + internal class Auto :Fahrzeug + { + public Auto(string kennzeichen) : base(kennzeichen) + { + + } + public override void Fahren() + { + Console.WriteLine($"Das Auto {this.kennzeichen} fährt."); + } + + } +} diff --git a/BeispielÜberschreiben/Ballon.cs b/BeispielÜberschreiben/Ballon.cs new file mode 100644 index 0000000..2c2d33c --- /dev/null +++ b/BeispielÜberschreiben/Ballon.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielÜberschreiben +{ + internal class Ballon : Fahrzeug + { + public Ballon(string kennzeichen) : base(kennzeichen) + { + + } + public override void Fahren() + { + Console.WriteLine($"Der Ballon {this.kennzeichen} fährt."); + } + } +} diff --git a/BeispielÜberschreiben/BeispielÜberschreiben.csproj b/BeispielÜberschreiben/BeispielÜberschreiben.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/BeispielÜberschreiben/BeispielÜberschreiben.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/BeispielÜberschreiben/Fahrzeug.cs b/BeispielÜberschreiben/Fahrzeug.cs new file mode 100644 index 0000000..89812d0 --- /dev/null +++ b/BeispielÜberschreiben/Fahrzeug.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielÜberschreiben +{ + internal class Fahrzeug + { + protected string kennzeichen; + + public Fahrzeug(string kennzeichen) + { + this.kennzeichen = kennzeichen; + } + public virtual void Fahren() + { + Console.WriteLine($"Das Fahrzeug {kennzeichen} fährt."); + } + public override string ToString() + { + return $"Fahrzeug: {this.kennzeichen}"; + } + } +} diff --git a/BeispielÜberschreiben/Program.cs b/BeispielÜberschreiben/Program.cs new file mode 100644 index 0000000..7867c04 --- /dev/null +++ b/BeispielÜberschreiben/Program.cs @@ -0,0 +1,28 @@ +namespace BeispielÜberschreiben +{ + internal class Program + { + static void Main(string[] args) + { + Fahrzeug[] fahrzeuge = new Fahrzeug[5]; + + fahrzeuge[0] = new Fahrzeug("AB-CD 123"); + fahrzeuge[1] = new Auto("XY-Z 987"); + fahrzeuge[2] = new Schiff("Evergiven"); + fahrzeuge[3] = new Ballon("Veltins"); + fahrzeuge[4] = new Fahrzeug("GH-IJ 567"); + + foreach (Fahrzeug item in fahrzeuge) + { + item.Fahren(); + } + + Fahrzeug f1 = fahrzeuge[0]; + Console.WriteLine(f1); + Console.WriteLine(f1.GetHashCode()); + Console.WriteLine(f1.Equals(fahrzeuge[0])); + Console.WriteLine(f1.Equals(fahrzeuge[1])); + Console.WriteLine(f1.GetType()); + } + } +} \ No newline at end of file diff --git a/BeispielÜberschreiben/Schiff.cs b/BeispielÜberschreiben/Schiff.cs new file mode 100644 index 0000000..ededae1 --- /dev/null +++ b/BeispielÜberschreiben/Schiff.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeispielÜberschreiben +{ + internal class Schiff : Fahrzeug + { + public Schiff(string kennzeichen) : base(kennzeichen) + { + + } + public override void Fahren() + { + Console.WriteLine($"Das Schiff {this.kennzeichen} fährt."); + } + } +} diff --git a/Overload/Overload.csproj b/Overload/Overload.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Overload/Overload.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Overload/Program.cs b/Overload/Program.cs new file mode 100644 index 0000000..b81fed5 --- /dev/null +++ b/Overload/Program.cs @@ -0,0 +1,23 @@ +namespace Overload +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine(Addiere(21,21)); + Console.WriteLine(Addiere(10,10,22)); + } + static int Addiere(int zahl1, int zahl2) + { + return zahl1 + zahl2; + } + static int Addiere(int zahl1, int zahl2, int zahl3) + { + return zahl1 + zahl2 + zahl3; + } + static double Addiere(double zahl1, int zahl2) + { + return zahl1 + zahl2; + } + } +} \ No newline at end of file diff --git a/Papier/Papier.csproj b/Papier/Papier.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Papier/Papier.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Papier/Program.cs b/Papier/Program.cs new file mode 100644 index 0000000..74e36ce --- /dev/null +++ b/Papier/Program.cs @@ -0,0 +1,28 @@ +namespace Papier +{ + internal class Program + { + static void Main(string[] args) + { + Flaeche papier = new Flaeche(); + Console.Write("Länge eingeben: "); + papier.SetLaenge(Convert.ToDouble(Console.ReadLine())); + Console.Write("Breite eingeben: "); + papier.SetBreite(Convert.ToDouble(Console.ReadLine())); + Console.WriteLine($"Die Länge beträgt {papier.GetLaenge():F2} cm, die Breite beträgt {papier.GetBreite():F2} cm und die Fälche beträgt {papier.GetFlaeche():F2} qm"); + } + } + class Flaeche + { + private double breite; + private double laenge; + public void SetBreite(double b) + { breite = b; } + public void SetLaenge(double l) + { laenge = l; } + public double GetBreite() { return breite; } + public double GetLaenge() { return laenge; } + public double GetFlaeche() + { return ((GetBreite()/100) * (GetLaenge()/100)); } + } +} \ No newline at end of file diff --git a/Papier2/Papier2.csproj b/Papier2/Papier2.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Papier2/Papier2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Papier2/Program.cs b/Papier2/Program.cs new file mode 100644 index 0000000..49a4aac --- /dev/null +++ b/Papier2/Program.cs @@ -0,0 +1,44 @@ +namespace Papier2 +{ + internal class Program + { + static void Main(string[] args) + { + Papier a4 = new Papier(29.7, 21); + //a4.SetLength(293.3); + //a4.SetWight(212); + a4.PrintInfos(); + } + } + + class Papier + { + private double lengthInCm; + private double widthInCm; + public Papier(double l, double w) + { + lengthInCm = l; + widthInCm = w; + } + public double GetLengthInCm() { return lengthInCm; } + //public void setlength(double l) + //{ + // if (lengthincm == 0 && 1 > 0) + // { lengthincm = l; } + //} + public double GetWidthInCm() { return widthInCm; } + //public void SetWight(double w) + //{ + // if (widthInCm == 0 && w > 0) + // { widthInCm = w; } + //} + public double GetArea() + { return GetLengthInCm() * GetWidthInCm(); } + public void PrintInfos() + { + Console.Write($"Das Papier mit der Länge {GetLengthInCm():F2} cm"); + Console.Write($" und der Breite {GetWidthInCm():F2} cm"); + Console.WriteLine($" hat eine Fläche von {GetArea()/10000:F2} Quadratmeter."); + } + } +} \ No newline at end of file diff --git a/Persona2/Persona2.csproj b/Persona2/Persona2.csproj new file mode 100644 index 0000000..5eb1e84 --- /dev/null +++ b/Persona2/Persona2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + disable + + + diff --git a/Persona2/Program.cs b/Persona2/Program.cs new file mode 100644 index 0000000..7a2c048 --- /dev/null +++ b/Persona2/Program.cs @@ -0,0 +1,64 @@ +using System.Net.NetworkInformation; +using System.Xml.Serialization; + +namespace Persona2 +{ + internal class Program + { + static void Main(string[] args) + { + Person p = new Person(); + + p.SetName("Osama"); + p.SetAge(35); + p.SayHello(); + p.Birthday(); + p.SayHello(); + + Person p2 = new Person(); + p2.SetName("Polly"); + p2.SetAge(27); + p2.SayHello(); + p2.Birthday(); + p2.SayHello(); + + Person p3 = new Person(); + p3.SetName("Anton"); + p3.SetAge(30); + p3.SayHello(); + p3.Birthday(); + p3.SayHello(); + + Console.WriteLine(); + Console.WriteLine(); + } + + class Person + { + private int age; + private string name; + public string GetName() + { return name; } + public void SetName(string n ) + { + if (name == null) + { name = n; } + } + public int GetAge() + { return age; } + public void SetAge(int a) + { + if ( age == 0 && a > 0) { age = a; } + } + public void Birthday () + { + age++; + } + public void SayHello() + { + Console.WriteLine($"Hallo mein Name ist {GetName()} und ich bin {GetAge()} Jahre alt."); + } + } + + } +} \ No newline at end of file diff --git a/SammelmappeFuerOop.sln b/SammelmappeFuerOop.sln new file mode 100644 index 0000000..ed53358 --- /dev/null +++ b/SammelmappeFuerOop.sln @@ -0,0 +1,133 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33424.131 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SammelmappeFuerOop", "SammelmappeFuerOop\SammelmappeFuerOop.csproj", "{699CB416-405A-4314-BD0C-9DE5B61DDBF3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persona2", "Persona2\Persona2.csproj", "{FB7068C6-D93A-471B-938F-35F95219ADA0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Papier", "Papier\Papier.csproj", "{8928E2FB-D59A-48F5-85A9-6C38C2B8A83C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Papier2", "Papier2\Papier2.csproj", "{FE15846E-BAE2-4F6C-9E3B-C1A06FE95D81}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Overload", "Overload\Overload.csproj", "{5FF9E609-C108-48E6-84A3-BAAC88C6F9F6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielConstructur", "BeispielConstructur\BeispielConstructur.csproj", "{402E879F-9B74-4599-9971-874D683E14B3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sweatshirt", "Sweatshirt\Sweatshirt.csproj", "{11126200-5613-477E-B5F4-5664C4FD176F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sweatshirt2", "Sweatshirt2\Sweatshirt2.csproj", "{F8836853-B0CD-4135-AA42-846F59F8E659}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielProperties", "BeispielProperties\BeispielProperties.csproj", "{79224946-C1BC-4D1E-9678-C42F27A81E40}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielStatic", "BeispielStatic\BeispielStatic.csproj", "{6A1F5208-6E19-4A20-B720-D8E94002063D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spielerkader", "Spielerkader\Spielerkader.csproj", "{93D813B7-1FF2-414F-8044-604F090C617B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spielerkarder2", "Spielerkarder2\Spielerkarder2.csproj", "{A760C3A3-594D-40DD-B583-EA7A8A21FD36}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielThis", "BeispielThis\BeispielThis.csproj", "{9CA7D9AE-BB3F-49FA-8DF5-B75A4AB56075}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielAbhängigkeiten", "BeispielAbhängigkeiten\BeispielAbhängigkeiten.csproj", "{DB316C3B-5298-427B-A2DE-E39A816710B2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielAssoziation", "BeispielAssoziation\BeispielAssoziation.csproj", "{31A78645-D722-4371-AA9B-2D0B10B85D5A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielAggregation", "BeispielAggregation\BeispielAggregation.csproj", "{79AB8204-AA22-4A28-89A4-2F2119879F8D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielKomposition", "BeispielKomposition\BeispielKomposition.csproj", "{662D8C81-E2F1-433F-91BC-6159647D7ECB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielVererbung", "BeispielVererbung\BeispielVererbung.csproj", "{9833AF5B-2E01-41EA-AD1A-49D2159940FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeispielÜberschreiben", "BeispielÜberschreiben\BeispielÜberschreiben.csproj", "{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {699CB416-405A-4314-BD0C-9DE5B61DDBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {699CB416-405A-4314-BD0C-9DE5B61DDBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {699CB416-405A-4314-BD0C-9DE5B61DDBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {699CB416-405A-4314-BD0C-9DE5B61DDBF3}.Release|Any CPU.Build.0 = Release|Any CPU + {FB7068C6-D93A-471B-938F-35F95219ADA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FB7068C6-D93A-471B-938F-35F95219ADA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB7068C6-D93A-471B-938F-35F95219ADA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FB7068C6-D93A-471B-938F-35F95219ADA0}.Release|Any CPU.Build.0 = Release|Any CPU + {8928E2FB-D59A-48F5-85A9-6C38C2B8A83C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8928E2FB-D59A-48F5-85A9-6C38C2B8A83C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8928E2FB-D59A-48F5-85A9-6C38C2B8A83C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8928E2FB-D59A-48F5-85A9-6C38C2B8A83C}.Release|Any CPU.Build.0 = Release|Any CPU + {FE15846E-BAE2-4F6C-9E3B-C1A06FE95D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE15846E-BAE2-4F6C-9E3B-C1A06FE95D81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE15846E-BAE2-4F6C-9E3B-C1A06FE95D81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE15846E-BAE2-4F6C-9E3B-C1A06FE95D81}.Release|Any CPU.Build.0 = Release|Any CPU + {5FF9E609-C108-48E6-84A3-BAAC88C6F9F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FF9E609-C108-48E6-84A3-BAAC88C6F9F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FF9E609-C108-48E6-84A3-BAAC88C6F9F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FF9E609-C108-48E6-84A3-BAAC88C6F9F6}.Release|Any CPU.Build.0 = Release|Any CPU + {402E879F-9B74-4599-9971-874D683E14B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {402E879F-9B74-4599-9971-874D683E14B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {402E879F-9B74-4599-9971-874D683E14B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {402E879F-9B74-4599-9971-874D683E14B3}.Release|Any CPU.Build.0 = Release|Any CPU + {11126200-5613-477E-B5F4-5664C4FD176F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11126200-5613-477E-B5F4-5664C4FD176F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11126200-5613-477E-B5F4-5664C4FD176F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11126200-5613-477E-B5F4-5664C4FD176F}.Release|Any CPU.Build.0 = Release|Any CPU + {F8836853-B0CD-4135-AA42-846F59F8E659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8836853-B0CD-4135-AA42-846F59F8E659}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8836853-B0CD-4135-AA42-846F59F8E659}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8836853-B0CD-4135-AA42-846F59F8E659}.Release|Any CPU.Build.0 = Release|Any CPU + {79224946-C1BC-4D1E-9678-C42F27A81E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79224946-C1BC-4D1E-9678-C42F27A81E40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79224946-C1BC-4D1E-9678-C42F27A81E40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79224946-C1BC-4D1E-9678-C42F27A81E40}.Release|Any CPU.Build.0 = Release|Any CPU + {6A1F5208-6E19-4A20-B720-D8E94002063D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A1F5208-6E19-4A20-B720-D8E94002063D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A1F5208-6E19-4A20-B720-D8E94002063D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A1F5208-6E19-4A20-B720-D8E94002063D}.Release|Any CPU.Build.0 = Release|Any CPU + {93D813B7-1FF2-414F-8044-604F090C617B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93D813B7-1FF2-414F-8044-604F090C617B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93D813B7-1FF2-414F-8044-604F090C617B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93D813B7-1FF2-414F-8044-604F090C617B}.Release|Any CPU.Build.0 = Release|Any CPU + {A760C3A3-594D-40DD-B583-EA7A8A21FD36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A760C3A3-594D-40DD-B583-EA7A8A21FD36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A760C3A3-594D-40DD-B583-EA7A8A21FD36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A760C3A3-594D-40DD-B583-EA7A8A21FD36}.Release|Any CPU.Build.0 = Release|Any CPU + {9CA7D9AE-BB3F-49FA-8DF5-B75A4AB56075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CA7D9AE-BB3F-49FA-8DF5-B75A4AB56075}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CA7D9AE-BB3F-49FA-8DF5-B75A4AB56075}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CA7D9AE-BB3F-49FA-8DF5-B75A4AB56075}.Release|Any CPU.Build.0 = Release|Any CPU + {DB316C3B-5298-427B-A2DE-E39A816710B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB316C3B-5298-427B-A2DE-E39A816710B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB316C3B-5298-427B-A2DE-E39A816710B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB316C3B-5298-427B-A2DE-E39A816710B2}.Release|Any CPU.Build.0 = Release|Any CPU + {31A78645-D722-4371-AA9B-2D0B10B85D5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31A78645-D722-4371-AA9B-2D0B10B85D5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31A78645-D722-4371-AA9B-2D0B10B85D5A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31A78645-D722-4371-AA9B-2D0B10B85D5A}.Release|Any CPU.Build.0 = Release|Any CPU + {79AB8204-AA22-4A28-89A4-2F2119879F8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79AB8204-AA22-4A28-89A4-2F2119879F8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79AB8204-AA22-4A28-89A4-2F2119879F8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79AB8204-AA22-4A28-89A4-2F2119879F8D}.Release|Any CPU.Build.0 = Release|Any CPU + {662D8C81-E2F1-433F-91BC-6159647D7ECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {662D8C81-E2F1-433F-91BC-6159647D7ECB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {662D8C81-E2F1-433F-91BC-6159647D7ECB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {662D8C81-E2F1-433F-91BC-6159647D7ECB}.Release|Any CPU.Build.0 = Release|Any CPU + {9833AF5B-2E01-41EA-AD1A-49D2159940FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9833AF5B-2E01-41EA-AD1A-49D2159940FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9833AF5B-2E01-41EA-AD1A-49D2159940FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9833AF5B-2E01-41EA-AD1A-49D2159940FD}.Release|Any CPU.Build.0 = Release|Any CPU + {4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3878952F-3D5B-4648-82B7-8FA8BF47063B} + EndGlobalSection +EndGlobal diff --git a/SammelmappeFuerOop/Program.cs b/SammelmappeFuerOop/Program.cs new file mode 100644 index 0000000..8682619 --- /dev/null +++ b/SammelmappeFuerOop/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Security.Principal; + +namespace Person_03_03_2023 +{ + internal class Program + { + static void Main(string[] args) + { + Person person = new Person(); + Console.WriteLine("Bitte stell dich vor. "); + person.SetName(Console.ReadLine()); + Console.WriteLine("{0} bitte sag uns bitte dein alter.", person.GetName()); + person.SetAge(Convert.ToInt32(Console.ReadLine())); + Console.WriteLine("{0} bitte sag uns noch wann dein Geburtstag ist.", person.GetName()); + person.SetDay(Console.ReadLine()); + } + } + class Person + { + private string name; + private int age; + private string day; + public string GetName() + { return name; } + public void SetName(string n) + { name = n; } + public int GetAge() + { + if (string.IsNullOrEmpty(day)) + { return age; } + else + { return age + 1; } + } + public void SetAge(int a) + { age = a; } + public void SetDay(string d) + { day = d; } + public string GetDay() + { return day; } + public void AusGabe() + { + if (string.IsNullOrEmpty(GetDay())) + { Console.WriteLine($"{GetName()} leider hattest du noch kein Geburtstag {GetAge()}."); } + else + { Console.WriteLine($"{GetName()} du bist ein Jahr älter als du angegeben hast {GetAge()}."); } + } + } +} \ No newline at end of file diff --git a/SammelmappeFuerOop/SammelmappeFuerOop.csproj b/SammelmappeFuerOop/SammelmappeFuerOop.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/SammelmappeFuerOop/SammelmappeFuerOop.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Spielerkader/Program.cs b/Spielerkader/Program.cs new file mode 100644 index 0000000..54a3eb6 --- /dev/null +++ b/Spielerkader/Program.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Spielerkader +{ + internal class Program + { + static void Main(string[] args) + { + string[] liste = { "Spieler1", "Spieler2", "Spieler3" }; + Spieler spieler = new Spieler(liste[0]); + spieler.GetInfo(); + } + class Spieler + { + private string name; + private int transferGebuer; + private int marktWert; + private Random random = new Random(); + //**constructor** + public Spieler(string name) + { + this.name = name; + MarktWertZufall(); + SetTransferGebuer(); + } + //**random number** + public void MarktWertZufall() + { this.marktWert = random.Next(10000, 1000000); } + //**playername** + public string GetName() { return name; } + //**market value of the players** + public int GetMarktwert() { return marktWert; } + //**Transfer fee for sale** + public void SetTransferGebuer() + { this.transferGebuer = random.Next(10000, 1000000); } + public void GetInfo() + { + Console.WriteLine($"{name}, {transferGebuer}, {marktWert}"); + } + } + } +} \ No newline at end of file diff --git a/Spielerkader/Spielerkader.csproj b/Spielerkader/Spielerkader.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Spielerkader/Spielerkader.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Spielerkarder2/Program.cs b/Spielerkarder2/Program.cs new file mode 100644 index 0000000..a30b024 --- /dev/null +++ b/Spielerkarder2/Program.cs @@ -0,0 +1,88 @@ +namespace Spielerkarder2 +{ + internal class Program + { + static void Main(string[] args) + { + Spieler[] mannschaft = new Spieler[11]; + for (int i = 0; i < mannschaft.Length; i++) + { + mannschaft[i] = new Spieler("Spieler " + (i + 1)); + } + //Änderung der Marktwerte für 34 Spieltage + for (int spieltag = 0; spieltag < 34; spieltag++) + { + for (int spieler = 0; spieler < mannschaft.Length; spieler++) + { + mannschaft[spieler].MarktwertZufall(); + } + } + foreach (Spieler spieler in mannschaft) + { + spieler.PrintInfos(); + spieler.MarktwertZufall(); + spieler.PrintInfos(); + Console.WriteLine(); + } + Spieler.PrintInfosAll(); + foreach (Spieler spieler in mannschaft) + { + spieler.PrintInfos(); + } + Spieler.Verkauf(); + } + class Spieler + { + private string name; + private int transfergeb; + private int marktwert; + private Random rnd = new Random(); + + private static int trasfergebAll; + private static int marktwertAll; + + + public Spieler(string name) + { + this.name = name; + this.transfergeb = rnd.Next(1, 10) * 1_000_000; + this.marktwert = this.transfergeb; + trasfergebAll += transfergeb; + marktwertAll += marktwertAll; + } + public void PrintInfos() + { + Console.WriteLine($"Name: {name}"); + Console.WriteLine($"Transfergeb.: {transfergeb}"); + Console.WriteLine($"Marktwert: {marktwert}"); + } + public static void PrintInfosAll() + { + Console.WriteLine($"Gesamte Transfergeb.: {trasfergebAll}"); + Console.WriteLine($"Gesamter Marktwert: {marktwertAll}"); + } + public void MarktwertZufall() + { + int abweichung = rnd.Next(10) * 10_000 - 30_000; + this.marktwert += abweichung; + marktwertAll += abweichung; + } + public static void Verkauf() + { + if (marktwertAll > trasfergebAll) + { + Console.WriteLine("Der verkauf lohnt sich."); + } + else if (marktwertAll < trasfergebAll) + { + Console.WriteLine("Der Verkauf lohnt sich nicht."); + } + else + { + Console.WriteLine("Wir machen weder Gewinn noch Verlust."); + } + } + + } + } +} \ No newline at end of file diff --git a/Spielerkarder2/Spielerkarder2.csproj b/Spielerkarder2/Spielerkarder2.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Spielerkarder2/Spielerkarder2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Sweatshirt/Program.cs b/Sweatshirt/Program.cs new file mode 100644 index 0000000..f92f4bd --- /dev/null +++ b/Sweatshirt/Program.cs @@ -0,0 +1,73 @@ +namespace Sweatshirt +{ + internal class Program + { + static void Main(string[] args) + { + Sweatshirt dry = new Sweatshirt(); + Sweatshirt wash = new Sweatshirt(); + Sweatshirt shirt1 = new Sweatshirt("lila", 36, true); + Sweatshirt shirt2 = new Sweatshirt(); + shirt1.GetInfo(); + Console.Write("You will wash you're Shirt? "); + wash.SetWash(Console.ReadLine()); + wash.GetWash(); + Console.Write("You will dry you're Shirt? "); + dry.SetDry(Console.ReadLine()); + dry.GetDry(); + shirt2.GetInfo(); + Console.Write("You will wash you're Shirt? "); + wash.SetWash(Console.ReadLine()); + wash.GetWash(); + Console.Write("You will dry you're Shirt? "); + dry.SetDry(Console.ReadLine()); + dry.GetDry(); + } + } + class Sweatshirt + { + //**Attribute** + private string color; + private int size; + private bool isDry; + private string wash; + private string dry; + //**constructor** + public Sweatshirt(string color, int size, bool isDry) { this.color = color; this.size = size; this.isDry = isDry; } + public Sweatshirt(int size) : this("red", size, true) { } + public Sweatshirt(bool isDry) : this("blau", 50, isDry) { } + public Sweatshirt(string color) : this(color, 50, true) { } + public Sweatshirt(string color, int size) : this(color, size, true) { } + public Sweatshirt(string color, bool isDry) : this(color, 50, isDry) { } + public Sweatshirt(int size, bool isDry) : this("grün", size, isDry) { } + public Sweatshirt() : this("braun", 25, false) { } + public bool GetIsDry() { return isDry; } + public int GetSize() { return size; } + public string GetColor() { return color; } + //**wish** + public void SetWash(string wash) + { this.wash = wash; } + public void SetDry(string dry) + { this.dry = dry; } + public string GetWash() + { + if (!string.IsNullOrEmpty(this.wash) && this.wash == "yes") + { Console.WriteLine("it's washed"); return wash; } + else + { Console.WriteLine("it's dry"); return ""; } + } + public string GetDry() + { + if (!string.IsNullOrEmpty(this.dry) && this.dry == "yes") + { Console.WriteLine("it's dry"); return dry; } + else + { Console.WriteLine("it's wet"); return ""; } + } + //**infoprint** + public void GetInfo() + { + string text = isDry ? "dry" : "wet"; + Console.WriteLine($"Color: {GetColor()}, size: {GetSize()}, is it dry? {text}"); + } + } +} \ No newline at end of file diff --git a/Sweatshirt/Sweatshirt.csproj b/Sweatshirt/Sweatshirt.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Sweatshirt/Sweatshirt.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Sweatshirt2/Program.cs b/Sweatshirt2/Program.cs new file mode 100644 index 0000000..31a1616 --- /dev/null +++ b/Sweatshirt2/Program.cs @@ -0,0 +1,81 @@ +namespace Sweatshirt +{ + internal class Program + { + static void Main(string[] args) + { + Sweatshirt dry = new Sweatshirt(); + Sweatshirt wash = new Sweatshirt(); + Sweatshirt shirt1 = new Sweatshirt("lila", Size.XL, true); + Sweatshirt shirt2 = new Sweatshirt(); + shirt1.GetInfo(); + Console.Write("You will wash you're Shirt? "); + wash.SetWash(Console.ReadLine()); + wash.GetWash(); + Console.Write("You will dry you're Shirt? "); + dry.SetDry(Console.ReadLine()); + dry.GetDry(); + shirt2.GetInfo(); + Console.Write("You will wash you're Shirt? "); + wash.SetWash(Console.ReadLine()); + wash.GetWash(); + Console.Write("You will dry you're Shirt? "); + dry.SetDry(Console.ReadLine()); + dry.GetDry(); + } + } + + enum Size + { + XS, S, M, L, XL, XXL + } + class Sweatshirt + { + //**Attribute** + private string color; + private Size size; + private bool isDry; + private string wash; + private string dry; + //**constructor** + public Sweatshirt(string color, Size size, bool isDry) + { + this.color = color; this.size = size; this.isDry = isDry; + } + public Sweatshirt(Size size) : this("red", size, true) { } + public Sweatshirt(bool isDry) : this("blau", Size.XL, isDry) { } + public Sweatshirt(string color) : this(color, Size.XL, true) { } + public Sweatshirt(string color, Size size) : this(color, size, true) { } + public Sweatshirt(string color, bool isDry) : this(color, Size.XL, isDry) { } + public Sweatshirt(Size size, bool isDry) : this("grün", size, isDry) { } + public Sweatshirt() : this("braun", Size.S, false) { } + public bool GetIsDry() { return isDry; } + public Size GetSize() { return size; } + public string GetColor() { return color; } + //**wish** + public void SetWash(string wash) + { this.wash = wash; } + public void SetDry(string dry) + { this.dry = dry; } + public string GetWash() + { + if (!string.IsNullOrEmpty(this.wash) && this.wash == "yes") + { Console.WriteLine("it's washed"); return wash; } + else + { Console.WriteLine("it's dry"); return ""; } + } + public string GetDry() + { + if (!string.IsNullOrEmpty(this.dry) && this.dry == "yes") + { Console.WriteLine("it's dry"); return dry; } + else + { Console.WriteLine("it's wet"); return ""; } + } + //**infoprint** + public void GetInfo() + { + string text = isDry ? "dry" : "wet"; + Console.WriteLine($"Color: {GetColor()}, size: {GetSize()}, is it dry? {text}"); + } + } +} \ No newline at end of file diff --git a/Sweatshirt2/Sweatshirt2.csproj b/Sweatshirt2/Sweatshirt2.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Sweatshirt2/Sweatshirt2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + +