diff --git a/P02 Methoden/Program.cs b/P02 Methoden/Program.cs index 3fcde6550ab15568f43221ce03f6cd8bad68d15b..941a2984b5d278b389e07ac4a7480f2ad16fdfa2 100644 --- a/P02 Methoden/Program.cs +++ b/P02 Methoden/Program.cs @@ -19,6 +19,13 @@ { return (1, 2); } + + static int Mal2(int x) + { + return 2 * x; + } + static int Mal3(int x) => 3 * x; + static void Main(string[] args) { int n = 5; diff --git a/P03 Klassen/Perso.cs b/P03 Klassen/Perso.cs new file mode 100644 index 0000000000000000000000000000000000000000..de14b385f5b3dab55f9018f74c363b523a7d26d8 --- /dev/null +++ b/P03 Klassen/Perso.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P03_Klassen +{ + class Perso + { + private static int naechstePersId = 1000; + public static int NaechstePersId + { + get => naechstePersId; + set + { + if (value < naechstePersId) + throw new ArgumentException("PersId muss größer sein"); + naechstePersId = value; + } + } + readonly string Name; + public int Alter + { + get => xyz01233; + //{ return xyz01233; } + + private set + { + if (value < 0) + throw new ArgumentOutOfRangeException("Wert mus positive Zahl sein"); + xyz01233 = value; + } + } + private int persID; + public int PersId + { + get => persID; + private set + { + persID = value; + } + + } + + int xyz01233; + public Perso(string name, int alter) + { + this.Name = name; + Alter = alter; + PersId = naechstePersId; + naechstePersId++; + } + //public void xxx() { Name = "N.N."; } + public void Ausgabe() + { + Console.WriteLine($"Name: {Name}, Alter: {Alter}"); + } + } +} diff --git a/P03 Klassen/Program.cs b/P03 Klassen/Program.cs index 02b76d81984b10a7dc945f8d57672032ed341286..a30bdb703689a971b7deb071cd718fccb6676398 100644 --- a/P03 Klassen/Program.cs +++ b/P03 Klassen/Program.cs @@ -1,56 +1,6 @@ namespace P03_Klassen { - class Perso - { - private static int naechstePersId = 1000; - public static int NaechstePersId - { - get => naechstePersId; - set - { - if (value < naechstePersId) - throw new ArgumentException("PersId muss größer sein"); - naechstePersId = value; - } - } - readonly string Name; - public int Alter - { - get => xyz01233; - //{ return xyz01233; } - - private set - { - if (value < 0) - throw new ArgumentOutOfRangeException("Wert mus positive Zahl sein"); - xyz01233 = value; - } - } - private int persID; - public int PersId - { - get => persID; - private set - { - persID = value; - } - - } - - int xyz01233; - public Perso(string name, int alter) - { - this.Name = name; - Alter = alter; - PersId = naechstePersId; - naechstePersId++; - } - //public void xxx() { Name = "N.N."; } - public void Ausgabe() - { - Console.WriteLine( $"Name: {Name}, Alter: {Alter}"); - } - } + internal class Program { static void Main(string[] args)