add Programmyday form github
This commit is contained in:
61
Parkplatz/Parkplatz.cs
Normal file
61
Parkplatz/Parkplatz.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Parkplatz
|
||||
{
|
||||
internal class Parkplatz
|
||||
{
|
||||
private int anzahlParkboxen;
|
||||
private Parkboxen[] parkboxen;
|
||||
public Parkplatz(int anzahlParkboxen)
|
||||
{
|
||||
this.anzahlParkboxen = anzahlParkboxen;
|
||||
this.parkboxen = new Parkboxen[anzahlParkboxen];
|
||||
for (int i = 0; i < parkboxen.Length; i++)
|
||||
{
|
||||
this.parkboxen[i] = new Parkboxen();
|
||||
}
|
||||
}
|
||||
|
||||
public bool parken(Auto auto)
|
||||
{
|
||||
for (int i = 0; i < parkboxen.Length; i++)
|
||||
{
|
||||
if (parkboxen[i].einparken(auto))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Auto ausparken(string kennzeichen)
|
||||
{
|
||||
for (int i = 0; i < anzahlParkboxen; i++)
|
||||
{
|
||||
Auto a = parkboxen[i].ausparken(kennzeichen);
|
||||
if (a != null)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void status()
|
||||
{
|
||||
Console.WriteLine("Parkplatz-Status: ");
|
||||
for (int i = 0; i < anzahlParkboxen; i++)
|
||||
{
|
||||
if (parkboxen[i].istleer())
|
||||
{
|
||||
Console.Write("[ ]");
|
||||
}
|
||||
else Console.Write("[X]");
|
||||
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user