-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
132 lines (111 loc) · 4.25 KB
/
Program.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
namespace Vehicle
{
class Program
{
static void Main(string[] args)
{
// using classes to instantiate new obejcts
Zero fxs = new Zero();
fxs.BatteryKWh = 77.7;
fxs.MainColor = "Blue";
fxs.MaximumOccupancy = "1";
fxs.CurrentChargePercentage = 10;
Zero fx = new Zero();
fxs.BatteryKWh = 77.7;
fxs.MainColor = "Purple";
fxs.MaximumOccupancy = "1";
fx.CurrentChargePercentage = 15;
Tesla modelS = new Tesla();
modelS.BatteryKWh = 101.1;
modelS.MainColor = "Black";
modelS.MaximumOccupancy = "5";
modelS.CurrentChargePercentage = 20;
Ram SLT = new Ram();
SLT.FuelCapacity = 99.9;
SLT.MainColor = "Red";
SLT.MaximumOccupancy = "4";
Cessna mx410 = new Cessna();
mx410.FuelCapacity = 88.8;
mx410.MainColor = "White";
mx410.MaximumOccupancy = "8";
// using interface to create list
List<IElectricVehicle> electricVehicles = new List<IElectricVehicle>()
{
// objects to be used in list
fx,
fxs,
modelS
};
// looping over with for each to grab the current charge off obejct.
// Writing out current charge percentage from objects
Console.WriteLine("Electric Vehicles");
foreach (IElectricVehicle ev in electricVehicles)
{
Console.WriteLine($"{ev.CurrentChargePercentage}");
}
// looping over with for each to grab the current charge off obejct and apply the Charge Battery method to it.
foreach (IElectricVehicle ev in electricVehicles)
{
// This method should charge the vehicle to 100%
ev.ChargeBattery();
}
// looping over with for each to grab the New current tank percentage off obejct.
// Writing out the new current charge percentage from object
foreach (IElectricVehicle ev in electricVehicles)
{
Console.WriteLine($"{ev.CurrentChargePercentage}");
}
Console.WriteLine("-------");
/***********************************************/
// using interface to create list
List<IGasVehicle> gasVehicles = new List<IGasVehicle>()
{
// objects to be used in list
SLT,
mx410
};
// looping over with for each to grab the current tank percentage off obejct.
// Writing out current tank percentage from objects
Console.WriteLine("Gas Vehicles");
foreach (IGasVehicle gv in gasVehicles)
{
Console.WriteLine($"{gv.CurrentTankPercentage}");
}
// looping over with for each to grab the current charge off obejct and apply the Refuel Tank method to it.
foreach (IGasVehicle gv in gasVehicles)
{
// This Method should completely refuel the gas tank
gv.RefuelTank();
}
// looping over with for each to grab the New current tank percentage off obejct.
// Writing out the new current charge percentage from object
foreach (IGasVehicle gv in gasVehicles)
{
Console.WriteLine($"{gv.CurrentTankPercentage}");
}
Console.WriteLine("-------");
// Calling methods on instantiated objects
modelS.Drive();
modelS.Turn();
modelS.Stop();
Console.WriteLine("-------");
fxs.Drive();
fxs.Turn();
fxs.Stop();
Console.WriteLine("-------");
fx.Drive();
fx.Turn();
fx.Stop();
Console.WriteLine("-------");
SLT.Drive();
SLT.Turn();
SLT.Stop();
Console.WriteLine("-------");
mx410.Turn();
mx410.Drive();
mx410.Stop();
}
}
}