Projektdateien hinzufügen.
This commit is contained in:
10
BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj
Normal file
10
BeispielAbhängigkeiten/BeispielAbhängigkeiten.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
21
BeispielAbhängigkeiten/Book.cs
Normal file
21
BeispielAbhängigkeiten/Book.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
17
BeispielAbhängigkeiten/Program.cs
Normal file
17
BeispielAbhängigkeiten/Program.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
BeispielAbhängigkeiten/Student.cs
Normal file
26
BeispielAbhängigkeiten/Student.cs
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
BeispielAggregation/BeispielAggregation.csproj
Normal file
10
BeispielAggregation/BeispielAggregation.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
44
BeispielAggregation/Class.cs
Normal file
44
BeispielAggregation/Class.cs
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
BeispielAggregation/Program.cs
Normal file
17
BeispielAggregation/Program.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
BeispielAggregation/Student.cs
Normal file
29
BeispielAggregation/Student.cs
Normal file
@@ -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()}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
10
BeispielAssoziation/BeispielAssoziation.csproj
Normal file
10
BeispielAssoziation/BeispielAssoziation.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
29
BeispielAssoziation/Class.cs
Normal file
29
BeispielAssoziation/Class.cs
Normal file
@@ -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()}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
22
BeispielAssoziation/Program.cs
Normal file
22
BeispielAssoziation/Program.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
BeispielAssoziation/Room.cs
Normal file
28
BeispielAssoziation/Room.cs
Normal file
@@ -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()}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielConstructur/BeispielConstructur.csproj
Normal file
10
BeispielConstructur/BeispielConstructur.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
31
BeispielConstructur/Program.cs
Normal file
31
BeispielConstructur/Program.cs
Normal file
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
10
BeispielKomposition/BeispielKomposition.csproj
Normal file
10
BeispielKomposition/BeispielKomposition.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
33
BeispielKomposition/Building.cs
Normal file
33
BeispielKomposition/Building.cs
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
BeispielKomposition/Floor.cs
Normal file
17
BeispielKomposition/Floor.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
12
BeispielKomposition/Program.cs
Normal file
12
BeispielKomposition/Program.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace BeispielKomposition
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Building b1 = new Building ("Trump-Tower", 15);
|
||||
|
||||
b1.PrintInfos();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielProperties/BeispielProperties.csproj
Normal file
10
BeispielProperties/BeispielProperties.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
61
BeispielProperties/Program.cs
Normal file
61
BeispielProperties/Program.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielStatic/BeispielStatic.csproj
Normal file
10
BeispielStatic/BeispielStatic.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
31
BeispielStatic/Program.cs
Normal file
31
BeispielStatic/Program.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielThis/BeispielThis.csproj
Normal file
10
BeispielThis/BeispielThis.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
36
BeispielThis/Program.cs
Normal file
36
BeispielThis/Program.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielVererbung/BeispielVererbung.csproj
Normal file
10
BeispielVererbung/BeispielVererbung.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
59
BeispielVererbung/Program.cs
Normal file
59
BeispielVererbung/Program.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
BeispielÜberschreiben/Auto.cs
Normal file
21
BeispielÜberschreiben/Auto.cs
Normal file
@@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
20
BeispielÜberschreiben/Ballon.cs
Normal file
20
BeispielÜberschreiben/Ballon.cs
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielÜberschreiben/BeispielÜberschreiben.csproj
Normal file
10
BeispielÜberschreiben/BeispielÜberschreiben.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
26
BeispielÜberschreiben/Fahrzeug.cs
Normal file
26
BeispielÜberschreiben/Fahrzeug.cs
Normal file
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
28
BeispielÜberschreiben/Program.cs
Normal file
28
BeispielÜberschreiben/Program.cs
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
20
BeispielÜberschreiben/Schiff.cs
Normal file
20
BeispielÜberschreiben/Schiff.cs
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Overload/Overload.csproj
Normal file
10
Overload/Overload.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
23
Overload/Program.cs
Normal file
23
Overload/Program.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Papier/Papier.csproj
Normal file
10
Papier/Papier.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
28
Papier/Program.cs
Normal file
28
Papier/Program.cs
Normal file
@@ -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)); }
|
||||
}
|
||||
}
|
||||
10
Papier2/Papier2.csproj
Normal file
10
Papier2/Papier2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
44
Papier2/Program.cs
Normal file
44
Papier2/Program.cs
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Persona2/Persona2.csproj
Normal file
10
Persona2/Persona2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
64
Persona2/Program.cs
Normal file
64
Persona2/Program.cs
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
133
SammelmappeFuerOop.sln
Normal file
133
SammelmappeFuerOop.sln
Normal file
@@ -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
|
||||
49
SammelmappeFuerOop/Program.cs
Normal file
49
SammelmappeFuerOop/Program.cs
Normal file
@@ -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()}."); }
|
||||
}
|
||||
}
|
||||
}
|
||||
10
SammelmappeFuerOop/SammelmappeFuerOop.csproj
Normal file
10
SammelmappeFuerOop/SammelmappeFuerOop.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
43
Spielerkader/Program.cs
Normal file
43
Spielerkader/Program.cs
Normal file
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Spielerkader/Spielerkader.csproj
Normal file
10
Spielerkader/Spielerkader.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
88
Spielerkarder2/Program.cs
Normal file
88
Spielerkarder2/Program.cs
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Spielerkarder2/Spielerkarder2.csproj
Normal file
10
Spielerkarder2/Spielerkarder2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
73
Sweatshirt/Program.cs
Normal file
73
Sweatshirt/Program.cs
Normal file
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Sweatshirt/Sweatshirt.csproj
Normal file
10
Sweatshirt/Sweatshirt.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
81
Sweatshirt2/Program.cs
Normal file
81
Sweatshirt2/Program.cs
Normal file
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Sweatshirt2/Sweatshirt2.csproj
Normal file
10
Sweatshirt2/Sweatshirt2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user