add Programmyday form github

This commit is contained in:
Ruben Kallinich
2024-07-25 15:47:46 +02:00
parent 09c8eab938
commit 7362c3d7ce
132 changed files with 3669 additions and 0 deletions

80
Moped/MitAnhänger.cs Normal file
View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Moped
{
internal class MitAnhänger : Moped
{
private int maxLoad;
private int currentLoad;
//public MitAnhänger(int kilometerstand, bool isSportModel, int maxLadeFläche) : base( kilometerstand, isSportModel)
//{
// this.licencePlate = "BIT-LC 1";
// this.odometer = kilometerstand;
// this.seats = 2;
// this.maxLadeFläche = maxLadeFläche;
//}
//public MitAnhänger(string kennzeichen, int kilometerstand, bool isSportModel, int maxLadeFläche) : base(kennzeichen, kilometerstand, isSportModel)
//{
// this.licencePlate = kennzeichen;
// this.odometer = kilometerstand;
// this.seats = 2;
// this.maxLadeFläche = maxLadeFläche;
//}
public MitAnhänger() : this(10, "BIT-LC 1") { }
public MitAnhänger(string licencePlate) : this(10, licencePlate) { }
public MitAnhänger(int maxLoad) : this(maxLoad, "BIT-LC 1") { }
public MitAnhänger(int maxLoad, string licencePlate) : base(licencePlate)
{
this.maxLoad = maxLoad;
}
public bool Load(int x)
{
if (x >= 0 && this.currentLoad + x <= this.maxLoad)
{
this.currentLoad += x;
Console.WriteLine($"Es wurden {x} Dinge aufgeladen.");
return true;
}
else
{
Console.WriteLine($"Es ist nicht genug Platz für {x} Dinge.");
return false;
}
}
public bool Unload(int x)
{
if (x >= 0 && this.currentLoad >= x)
{
this.currentLoad -= x;
Console.WriteLine($"Es wurden {x} Dinge abgeladen.");
return true;
}
else
{
Console.WriteLine($"Es sind keine {x} Dinge vorhanden.");
return false;
}
}
public int GetLoad()
{
return currentLoad;
}
//public override void GetInfos()
//{
// base.GetInfos();
// Console.WriteLine($"Die ladung des Anhängers beträgt {GetLoad()}");
// Console.WriteLine();
//}
public override void GetInfos()
{
base.GetInfos();
Console.WriteLine($"Ladefläche: {currentLoad}");
Console.WriteLine($"Ladefläche max: {maxLoad}");
}
}
}

80
Moped/Moped.cs Normal file
View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Moped
{
internal class Moped
{
protected string licencePlate;
protected int odometer;
protected int seats;
public Moped() : this("Bit-LC 1", false) { }
public Moped(bool IsSportModel) : this("BIT-LC 1", IsSportModel) { }
public Moped(string licenePlate) : this(licenePlate, false) { }
public Moped(string licencePlate, bool IsSportModel)
{
this.licencePlate = licencePlate;
this.seats = IsSportModel ? 1 : 0;
}
//public Moped(int kilometerstand, bool isSportModel)
//{
// this.licencePlate = "BIT-LC 1";
// this.odometer = kilometerstand;
// this.seats = isSportModel ? 1 : 2;
//}
//public Moped(string kennzeichen, int kilometerstand, bool isSportModel)
//{
// this.licencePlate = kennzeichen;
// this.odometer = kilometerstand;
// this.seats = isSportModel ? 1 : 2;
//}
public void Drive(int x)
{
this.odometer += x;
Console.WriteLine($"Das Moped fährt {x} Kilometer.");
}
public string GetLicensePlatte()
{
return this.licencePlate;
}
public int GetOdometer()
{
return this.odometer;
}
public int GetSeats()
{
if (seats == 1)
{
return this.seats = 1;
}
else
{
return this.seats = 2;
}
}
public virtual void GetInfos()
{
Console.WriteLine($"Kennzeichen: {GetLicensePlatte()}");
Console.WriteLine($"Kilometer: {GetOdometer()}");
Console.WriteLine($"Sitzsplätze: {GetSeats()}");
}
//public virtual void GetInfos()
//{
// Console.WriteLine($"Das Moped hat folgendes Kennzeichen:{licencePlate}");
// Console.WriteLine($"Das Moped hat folgenden Kilometerstand:{odometer}");
// if (this.seats == 1)
// {
// Console.WriteLine($"Sport Moped hat nur 1 Sitzsplatz");
// }
// else
// {
// Console.WriteLine($"Normale Mopeds haben 2 Sitzpätze");
// }
//}
}
}

10
Moped/Moped.csproj Normal file
View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

45
Moped/Program.cs Normal file
View File

@@ -0,0 +1,45 @@
namespace Moped
{
internal class Program
{
static void Main(string[] args)
{
//Moped m1 = new Moped(200, 0);
//Moped m2 = new Moped("UN DO : 022",200, 1);
//MitAnhänger ma1 = new MitAnhänger(200,2,30);
//m1.Drive(50);
//m1.GetInfos();
//Console.WriteLine();
//ma1.GetInfos();
//ma1.Load(15);
//ma1.GetInfos();
//ma1.Unload(4);
//ma1.GetInfos();
Moped[] mopeds = new Moped[4];
mopeds[0] = new Moped();
mopeds[1] = new Moped("xyz");
mopeds[2] = new Moped(true);
mopeds[3] = new Moped("ABC", true);
//mopeds[2].Drive(50);
//mopeds[0].Drive(100);
foreach (var item in mopeds)
{
item.GetInfos();
Console.WriteLine();
}
MitAnhänger ma1 = new MitAnhänger(100,"UN-IT 4666");
ma1.GetInfos();
Console.WriteLine();
mopeds[3] = ma1;
foreach (var item in mopeds)
{
item.GetInfos();
Console.WriteLine();
}
}
}
}