81 lines
2.6 KiB
C#
81 lines
2.6 KiB
C#
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}");
|
|
}
|
|
}
|
|
}
|