Commit 93aacd4e authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

Semesterstart

parent da6f11f0
{
"version": 2,
"dgSpecHash": "8QASeFsUfSSjUvRvUNspPzqFs6HyU4AbIaqy0SrraeSCtFVt4oBAjcGrGn33jVDx39i9AavlxSAhptgoyU2YqA==",
"success": true,
"projectFilePath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorOverloading\\01OperatorOverloading.csproj",
"expectedPackageFiles": [],
"logs": []
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_02Test</RootNamespace>
<RootNamespace>_01OperatorTrueFalse</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _01OperatorTrueFalse
{
public struct LaunchStatus
{
public static readonly LaunchStatus Green = new LaunchStatus(0);
public static readonly LaunchStatus Yellow = new LaunchStatus(1);
public static readonly LaunchStatus Red = new LaunchStatus(2);
private int status;
private LaunchStatus(int status)
{
this.status = status;
}
public static bool operator true(LaunchStatus x) => x == Green || x == Yellow;
public static bool operator false(LaunchStatus x) => x == Red;
public static LaunchStatus operator &(LaunchStatus x, LaunchStatus y)
{
if (x == Red || y == Red || (x == Yellow && y == Yellow))
{
return Red;
}
if (x == Yellow || y == Yellow)
{
return Yellow;
}
return Green;
}
public static bool operator ==(LaunchStatus x, LaunchStatus y) => x.status == y.status;
public static bool operator !=(LaunchStatus x, LaunchStatus y) => !(x == y);
public override bool Equals(object obj) => obj is LaunchStatus other && this == other;
public override int GetHashCode() => status;
}
public class LaunchStatusTest
{
public static void Main()
{
// Wichtig! Die nächste Zeile zeigt die Short-Cut-Evaluation durch das Überladen von
// true und false! Es erfolgt jeweils eine implizite Wandlung nach bool durch die
// Überladung von true und false. Daher wird GetNavigationLaunchStatus nur aufgerufen,
// wenn GetFuelLauchStatus gleich true ist!
LaunchStatus okToLaunch1 = GetFuelLaunchStatus() && GetNavigationLaunchStatus();
Console.WriteLine("----------------");
LaunchStatus okToLaunch2 = GetFuelLaunchStatus() & GetNavigationLaunchStatus();
// Nochmals: Durch das überladene true ist der nachfolgende Ausdruck zulässig!
Console.WriteLine("----------------");
Console.WriteLine(okToLaunch1 ? "Ready to go!" : "Wait!");
}
static LaunchStatus GetFuelLaunchStatus()
{
Console.WriteLine("Getting fuel launch status...");
return LaunchStatus.Red;
}
static LaunchStatus GetNavigationLaunchStatus()
{
Console.WriteLine("Getting navigation launch status...");
return LaunchStatus.Yellow;
}
}
}
......@@ -6,15 +6,15 @@
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"01Klassen_Wdhl/1.0.0": {
"01OperatorTrueFalse/1.0.0": {
"runtime": {
"01Klassen_Wdhl.dll": {}
"01OperatorTrueFalse.dll": {}
}
}
}
},
"libraries": {
"01Klassen_Wdhl/1.0.0": {
"01OperatorTrueFalse/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
......
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\03Test2\\03Test2.csproj": {}
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorTrueFalse\\01OperatorTrueFalse.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\03Test2\\03Test2.csproj": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorTrueFalse\\01OperatorTrueFalse.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\03Test2\\03Test2.csproj",
"projectName": "03Test2",
"projectPath": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\03Test2\\03Test2.csproj",
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorTrueFalse\\01OperatorTrueFalse.csproj",
"projectName": "01OperatorTrueFalse",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorTrueFalse\\01OperatorTrueFalse.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\Source\\Repos\\prog2-ss2020-wienkop\\03Test2\\obj\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\01OperatorTrueFalse\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
......
......@@ -11,12 +11,12 @@
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("03Test2")]
[assembly: System.Reflection.AssemblyCompanyAttribute("01OperatorTrueFalse")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("03Test2")]
[assembly: System.Reflection.AssemblyTitleAttribute("03Test2")]
[assembly: System.Reflection.AssemblyProductAttribute("01OperatorTrueFalse")]
[assembly: System.Reflection.AssemblyTitleAttribute("01OperatorTrueFalse")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.
......
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.exe
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.deps.json
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.runtimeconfig.json
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.runtimeconfig.dev.json
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.dll
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\bin\Debug\netcoreapp3.1\01OperatorTrueFalse.pdb
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.csprojAssemblyReference.cache
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.csproj.CoreCompileInputs.cache
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.AssemblyInfoInputs.cache
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.AssemblyInfo.cs
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.dll
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.pdb
C:\Users\wienkop\Source\Repos\prog2-ss2020-wienkop\01OperatorTrueFalse\obj\Debug\netcoreapp3.1\01OperatorTrueFalse.genruntimeconfig.cache
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment