-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVehicleTypes.cs
47 lines (45 loc) · 1.75 KB
/
VehicleTypes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace Ex03.GarageLogic
{
public class VehicleTypes
{
public enum eVehicleTypes
{
FuelCar,
FuelMotorcycle,
Truck,
ElectricCar,
ElectricMotorcycle
}
public static Vehicle CreateVehicle(int i_VehicleType, string i_VehicleLicenceNumber, string i_VehicleModelName, string i_WheelManufacturerName)
{
Vehicle vehicle;
switch (i_VehicleType)
{
case 1:
vehicle = new FuelCar(i_VehicleModelName, i_VehicleLicenceNumber, i_WheelManufacturerName);
vehicle = vehicle as FuelCar;
break;
case 2:
vehicle = new FuelMotorcycle(i_VehicleModelName, i_VehicleLicenceNumber, i_WheelManufacturerName);
vehicle = vehicle as FuelMotorcycle;
break;
case 4:
vehicle = new ElectricMotorcycle(i_VehicleModelName, i_VehicleLicenceNumber, i_WheelManufacturerName);
vehicle = vehicle as ElectricMotorcycle;
break;
case 5:
vehicle = new ElectricCar(i_VehicleModelName, i_VehicleLicenceNumber, i_WheelManufacturerName);
vehicle = vehicle as ElectricCar;
break;
case 3:
vehicle = new Truck(i_VehicleModelName, i_VehicleLicenceNumber, i_WheelManufacturerName);
vehicle = vehicle as Truck;
break;
default:
vehicle = null;
break;
}
return vehicle;
}
}
}