diff --git a/OOP2024_AMP.sln b/OOP2024_AMP.sln index 46b32a489550fd8b56a664311753b0e7eb3b01d5..b6a997a629e6dd469b5f340564339e6e1b4027e3 100644 --- a/OOP2024_AMP.sln +++ b/OOP2024_AMP.sln @@ -5,11 +5,11 @@ VisualStudioVersion = 17.9.34701.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OOP2024_AMP", "OOP2024_AMP.csproj", "{502C6032-97B3-48F1-A6CC-7F7990A17C42}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P01 Arrays", "..\P01 Arrays\P01 Arrays.csproj", "{380BF007-927D-4918-AB2C-DEDD526C626E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P01 Arrays", "P01 Arrays\P01 Arrays.csproj", "{4029AE1B-D229-4412-A364-97F133689051}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P03 Klassen", "..\P03 Klassen\P03 Klassen.csproj", "{2CBE1E64-D911-47BD-A32A-115629B62979}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P02 Methoden", "P02 Methoden\P02 Methoden.csproj", "{533F60DB-284B-4956-840E-8DF5204E6792}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P02 Methoden", "..\P02 Methoden\P02 Methoden.csproj", "{4F4B3446-6361-407B-BD69-33A73501D3A1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P03 Klassen", "P03 Klassen\P03 Klassen.csproj", "{E0E52007-EEDB-4075-9371-909D9E435F61}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,18 +21,18 @@ Global {502C6032-97B3-48F1-A6CC-7F7990A17C42}.Debug|Any CPU.Build.0 = Debug|Any CPU {502C6032-97B3-48F1-A6CC-7F7990A17C42}.Release|Any CPU.ActiveCfg = Release|Any CPU {502C6032-97B3-48F1-A6CC-7F7990A17C42}.Release|Any CPU.Build.0 = Release|Any CPU - {380BF007-927D-4918-AB2C-DEDD526C626E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {380BF007-927D-4918-AB2C-DEDD526C626E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {380BF007-927D-4918-AB2C-DEDD526C626E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {380BF007-927D-4918-AB2C-DEDD526C626E}.Release|Any CPU.Build.0 = Release|Any CPU - {2CBE1E64-D911-47BD-A32A-115629B62979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CBE1E64-D911-47BD-A32A-115629B62979}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2CBE1E64-D911-47BD-A32A-115629B62979}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2CBE1E64-D911-47BD-A32A-115629B62979}.Release|Any CPU.Build.0 = Release|Any CPU - {4F4B3446-6361-407B-BD69-33A73501D3A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F4B3446-6361-407B-BD69-33A73501D3A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F4B3446-6361-407B-BD69-33A73501D3A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F4B3446-6361-407B-BD69-33A73501D3A1}.Release|Any CPU.Build.0 = Release|Any CPU + {4029AE1B-D229-4412-A364-97F133689051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4029AE1B-D229-4412-A364-97F133689051}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4029AE1B-D229-4412-A364-97F133689051}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4029AE1B-D229-4412-A364-97F133689051}.Release|Any CPU.Build.0 = Release|Any CPU + {533F60DB-284B-4956-840E-8DF5204E6792}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {533F60DB-284B-4956-840E-8DF5204E6792}.Debug|Any CPU.Build.0 = Debug|Any CPU + {533F60DB-284B-4956-840E-8DF5204E6792}.Release|Any CPU.ActiveCfg = Release|Any CPU + {533F60DB-284B-4956-840E-8DF5204E6792}.Release|Any CPU.Build.0 = Release|Any CPU + {E0E52007-EEDB-4075-9371-909D9E435F61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0E52007-EEDB-4075-9371-909D9E435F61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/P01 Arrays/P01 Arrays.csproj b/P01 Arrays/P01 Arrays.csproj new file mode 100644 index 0000000000000000000000000000000000000000..73019f35ffc7c134ef7d02761980da6239ab4d0d --- /dev/null +++ b/P01 Arrays/P01 Arrays.csproj @@ -0,0 +1,11 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <RootNamespace>P01_Arrays</RootNamespace> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/P01 Arrays/Program.cs b/P01 Arrays/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..f34294093e10eee418579cff11551ab4bf47cd13 --- /dev/null +++ b/P01 Arrays/Program.cs @@ -0,0 +1,12 @@ +namespace P01_Arrays +{ + internal class Program + { + static void Main(string[] args) + { + int[] f1 = new int[10]; + int[] f2 = { 1, 2, 3, 4, 5 }; + Console.WriteLine(f1[10]); + } + } +} diff --git a/P02 Methoden/P02 Methoden.csproj b/P02 Methoden/P02 Methoden.csproj new file mode 100644 index 0000000000000000000000000000000000000000..b77cfdbad51165bb22e9276909aadf4700525915 --- /dev/null +++ b/P02 Methoden/P02 Methoden.csproj @@ -0,0 +1,11 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <RootNamespace>P02_Methoden</RootNamespace> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/P02 Methoden/Program.cs b/P02 Methoden/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..3fcde6550ab15568f43221ce03f6cd8bad68d15b --- /dev/null +++ b/P02 Methoden/Program.cs @@ -0,0 +1,31 @@ +namespace P02_Methoden +{ + internal class Program + { + static void Plus1(out double x, ref double y) + { + y= y + 2; + x = 5; + } + // ref ~ initialisierter Wert kommt hinein + // Wert kann verändert werden, muss aber nicht + // out ~ Variable muss in der Methode einen Wert erhalten + // (analog zu return) + // Variable kann vor dem Aufruf initialisiert sein + // muss aber nicht + static void Plus1(ref int x) { x= x + 1; } + + static (int,int) DoIt() + { + return (1, 2); + } + static void Main(string[] args) + { + int n = 5; + double a, b=1; + Plus1(out a, out b); + int k, l; + (k, l) = DoIt(); + } + } +} diff --git a/P03 Klassen/P03 Klassen.csproj b/P03 Klassen/P03 Klassen.csproj new file mode 100644 index 0000000000000000000000000000000000000000..83e90f0f8305e34c5a4f67ef450e702cd02599a1 --- /dev/null +++ b/P03 Klassen/P03 Klassen.csproj @@ -0,0 +1,11 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <RootNamespace>P03_Klassen</RootNamespace> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/P03 Klassen/P03 Klassen.sln b/P03 Klassen/P03 Klassen.sln new file mode 100644 index 0000000000000000000000000000000000000000..86090f2e751bb84da5a2b2ed1118d202a6cdbddd --- /dev/null +++ b/P03 Klassen/P03 Klassen.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34701.34 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P03 Klassen", "P03 Klassen.csproj", "{44F48F39-C70B-46AD-93EA-9D278EEA0DCF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {44F48F39-C70B-46AD-93EA-9D278EEA0DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44F48F39-C70B-46AD-93EA-9D278EEA0DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44F48F39-C70B-46AD-93EA-9D278EEA0DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44F48F39-C70B-46AD-93EA-9D278EEA0DCF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {127FC62F-BA28-412E-9D92-0BB25B7496B4} + EndGlobalSection +EndGlobal diff --git a/P03 Klassen/Program.cs b/P03 Klassen/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..02b76d81984b10a7dc945f8d57672032ed341286 --- /dev/null +++ b/P03 Klassen/Program.cs @@ -0,0 +1,69 @@ +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) + { + //Perso noName = new Perso("noName", -1); + //noName.NaechstePersId = 2000; + Perso.NaechstePersId = 2000; + Perso anton = new Perso("Anton", 22); + //anton.PersId = 333; -- nicht erlaubt,da private + anton.Ausgabe(); + //anton.NaechstePersId = 2000; + Perso berta = new Perso("Berta", 25); + + } + } +}