您最多选择25个主题
主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
50 行
1.7 KiB
50 行
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); |
|
} |
|
} |
|
}
|
|
|