A simple demonstration of OOP styles.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

50 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ParkingLot.Vehicles;
namespace ParkingLot
{
class Program
{
static void Main(string[] args)
{
ParkingLot parkingLot = ParkingLot.CreateParkingLot(5, 5, 20);
parkingLot.VehicleLeftEvent += ParkingLot_VehicleLeftEvent;
Console.WriteLine("Type 'add' to add a vehicle. 'exit' to close the program.");
bool run = true;
while (run)
{
string command = Console.ReadLine();
switch (command)
{
case "add":
Vehicle newVehicle = Vehicle.CreateVehicle(600);
bool success = parkingLot.AddVehicle(newVehicle);
if (success)
{
Console.WriteLine("{0} Parked Successfully at Level {1}, Row {2}, Space {3}", newVehicle.VehicleType, newVehicle.Level, newVehicle.Row, string.Join(",", newVehicle.Spaces));
}
else
{
Console.WriteLine("The parking lot was full for the {0}", newVehicle.VehicleType);
}
break;
case "exit":
run = false;
break;
default:
break;
}
}
}
private static void ParkingLot_VehicleLeftEvent(double price)
{
Console.WriteLine("Vehicle Left - Price: ${0}", price);
}
}
}