Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • schneider/prog2-ss2020-wienkop
  • Wienkop/prog2-ss2020-wienkop
2 results
Show changes
Showing
with 62 additions and 14 deletions
......@@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
......
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
c0523642d3f3714f80c0cf31b3f8720f51a0bc09
82aabe7d8f5e95a70e62a8056949f0852a121b56
No preview for this file type
No preview for this file type
No preview for this file type
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
......@@ -13,11 +13,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\01KlassenWiederholung.csproj",
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\01KlassenWiederholung.csproj",
"projectName": "01KlassenWiederholung",
"projectPath": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\01KlassenWiederholung.csproj",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\01KlassenWiederholung.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\obj\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
......@@ -58,7 +58,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.302\\RuntimeIdentifierGraph.json"
}
}
}
......
{
"version": 2,
"dgSpecHash": "d28s381XyCa+KWTqXqsiz1e5QDe2zjzOGLwD+TzLyTXr2j2Ojuk6oyT3rqPsCTolE0t5lTV2AtXFlwPkqpY87w==",
"dgSpecHash": "yf1mAuqnN9+dINSfpOnnNfcIQ4cJcAqxabhZAvoIvIfiJymi6G+yh848AC9sXbrAoZHxmP5z8I/XNhCBHEMbpg==",
"success": true,
"projectFilePath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01KlassenWiederholung\\01KlassenWiederholung.csproj",
"expectedPackageFiles": [],
......
using System;
using System.Runtime.CompilerServices;
namespace _01OperatorOverloading
{
......@@ -42,15 +43,33 @@ namespace _01OperatorOverloading
// nur wenn b1.z == b2.z ist, wird b1.n == b2.n ausgeführt
public static bool operator !=(Bruch b1, Bruch b2)
=> !(b1 == b2);
public static Bruch operator <<(Bruch b, int x) => new Bruch(b.z * x, b.n * x);
public static Bruch operator >>(Bruch b, int x) => new Bruch(b.z / x, b.n / x);
// Konvertierungsoperatoren:
public static explicit operator int(Bruch b)
=> b.z / b.n;
public static implicit operator double(Bruch b)
public static explicit operator double(Bruch b)
=> (double)b.z / (double)b.n;
public static implicit operator Bruch(int zahl)
=> new Bruch(zahl);
// Überladung unärer Operatoren:
public static Bruch operator +(Bruch b) => b;
public static Bruch operator -(Bruch b) => new Bruch(-b.z, b.n);
// ACHTUNG: Nur EINE Inkrement-/Dekrement- Implementierung angeben!
// Post- oder Pre-Inkrement/Dekrement werden vom Compiler generiert!
// Die folgenden beiden Zeilen sind also falsch!
//public static Bruch operator ++(Bruch b) { b.z += b.n; return b; }
//public static Bruch operator --(Bruch b) { b.z -= b.n; return b; }
// !!! So geht es richtig: x = 5; cw(x++)--> cw(x); x=x+1 , cw(++x) --> x=x+1;cw(x)
public static Bruch operator ++(Bruch b) { return new Bruch(b.z + b.n, b.n); }
public static Bruch operator --(Bruch b) { return new Bruch(b.z - b.n, b.n); }
public override string ToString() => $"{z} / {n}";
}
......@@ -59,6 +78,8 @@ namespace _01OperatorOverloading
{
static void Main(string[] args)
{
Console.WriteLine(2 << 3); // 10 << 3 --> 10 000
Console.WriteLine("***************");
Bruch b1 = new Bruch(2, 3);
Bruch b2 = new Bruch(2);
Bruch b3 = new Bruch("3/4");
......@@ -73,6 +94,7 @@ namespace _01OperatorOverloading
Bruch e3 = b1 * b2;
Bruch e4 = b1 * 2;
Bruch e5 = 2 * b1;
// Wir haben Bruch.operator*(Bruch, Bruch)
// int.op*, double.op*, Bruch.op*
// Bruch.op*(Bruch, Bruch)
......@@ -83,19 +105,33 @@ namespace _01OperatorOverloading
int k2 = 3 * (int)4.5;
int k = (int)e3; // explizite Konvertierung
double d = e3; // implizite Konvertierung
double d = (double) e3;
Console.WriteLine(k);
Console.WriteLine(d);
double d2 = (int)34;
int k3 = (int)3.5;
Bruch b4 = new Bruch(2, 5); // b4: neuer Speicher #100000
Bruch b5 = new Bruch(2, 5); // b5: neuer Speicher #200000
Bruch b4 = new Bruch(2, 5); // b4: neuer Speicher #100.000
Bruch b5 = new Bruch(2, 5); // b5: neuer Speicher #200.000
if (b4 == b5)
Console.WriteLine("Sind gleich");
else
Console.WriteLine("Sind unterschiedlich");
Bruch b6 = new Bruch(1, 2);
Console.WriteLine(b6++);
Console.WriteLine(++b6);
int x = 55;
Console.WriteLine(x++);
Console.WriteLine(++x);
Bruch b7 = new Bruch(1, 3);
Console.WriteLine(b7 << 2);
Bruch b8 = new Bruch(2, 4);
Console.WriteLine(-b8);
}
}
}
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -52,7 +52,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.302\\RuntimeIdentifierGraph.json"
}
}
}
......
......@@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
......
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
c0523642d3f3714f80c0cf31b3f8720f51a0bc09
80121664ed3059c23145d5fcd702eb3b2171d68d
No preview for this file type