Commit 40a25eb1 authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

2020-07-07 Di

parent 4687864a
......@@ -65,7 +65,7 @@ namespace _01OperatorOverloading
//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:
// !!! 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}";
......@@ -78,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");
......@@ -126,6 +128,9 @@ namespace _01OperatorOverloading
Bruch b7 = new Bruch(1, 3);
Console.WriteLine(b7 << 2);
Bruch b8 = new Bruch(2, 4);
Console.WriteLine(-b8);
}
}
}
......@@ -15,8 +15,14 @@ namespace _01OperatorTrueFalse
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 bool operator true(LaunchStatus x)
{
Console.WriteLine($"OP-true {x == Green || x == Yellow}"); return x == Green || x == Yellow;
}
public static bool operator false(LaunchStatus x)
{
Console.WriteLine($"OP-false: {x == Red}"); return x == Red;
}
public static LaunchStatus operator &(LaunchStatus x, LaunchStatus y)
{
......@@ -61,6 +67,9 @@ namespace _01OperatorTrueFalse
Console.WriteLine(okToLaunch1 ? "Ready to go!" : "Wait!");
// okToLaunch1 ---(op true)--> bool
//if (okToLaunch1.Equals(okToLaunch2))
Console.WriteLine( "*************");
if (okToLaunch1)
Console.WriteLine("okToLaunch1 = true");
}
static LaunchStatus GetFuelLaunchStatus()
......
Supports Markdown
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