-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
123 lines (108 loc) · 3.82 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
using System;
namespace Inheritance
{
public class Vehicle
{
public string MainColor { get; set; }
public string MaximumOccupancy { get; set; }
public virtual void Drive()
{
Console.WriteLine("Vrooom!");
}
public virtual void Turn(string direction){
Console.WriteLine($"Turning {direction}...");
}
public virtual void Stop(){
Console.WriteLine("Stopping...");
}
}
public class Zero : Vehicle
{ // Electric motorcycle
public double BatteryKWh { get; set; }
public void ChargeBattery() { Console.WriteLine("Charging..."); }
public override void Drive(){
Console.WriteLine($"The {MainColor} Zero drives past you. VVeeeyuuummmmmm!!");
}
public override void Turn(string direction){
Console.WriteLine($"The Zero sharply turns {direction}.");
}
}
public class Cessna : Vehicle
{ // Propellor light aircraft
public double FuelCapacity { get; set; }
public void RefuelTank() {Console.WriteLine("Refueling...");}
public override void Drive()
{
Console.WriteLine($"The {MainColor} Cessna drives past you. Shyoooommm!!");
}
public override void Turn(string direction){
Console.WriteLine($"The Cessna take a careful {direction} turn.");
}
public override void Stop(){
Console.WriteLine($"The {MainColor} descends to make a full and safe stop.");
}
}
public class Tesla : Vehicle
{ // Electric car
public double BatteryKWh { get; set; }
public void ChargeBattery() { Console.WriteLine("Charging..."); }
public override void Drive(){
Console.WriteLine($"The {MainColor} Tesla drives past you. You don't hear it...");
}
public override void Stop(){
Console.WriteLine($"The {MainColor} Tesla comes to a sharp stop. You don't hear it...");
}
}
public class Ram : Vehicle
{ // Gas powered truck
public double FuelCapacity { get; set; }
public void RefuelTank() {Console.WriteLine("Refueling...");}
public override void Drive(){
Console.WriteLine($"The {MainColor} Ram drives past you. VGGGRVRGRROOOOOOOMMMMM!!!!!");
}
public override void Turn(string direction){
Console.WriteLine($"The {MainColor} Ram pulls a {direction} turn.");
}
public override void Stop(){
Console.WriteLine($"The Ram stops completely.");
}
}
class Program
{
static void Main(string[] args)
{
Vehicle fxs = new Zero(){
BatteryKWh = 400,
MainColor = "green",
MaximumOccupancy = "5 Passengers"
};
Vehicle modelS = new Tesla(){
BatteryKWh = 650,
MainColor = "blue",
MaximumOccupancy = "5 Passengers"
};
Vehicle mx410 = new Cessna(){
FuelCapacity = 325,
MainColor = "white",
MaximumOccupancy = "2 Passengers"
};
Vehicle f250 = new Ram(){
FuelCapacity = 275,
MainColor = "black",
MaximumOccupancy = "6 Passengers"
};
fxs.Drive();
modelS.Drive();
mx410.Drive();
f250.Drive();
fxs.Stop();
modelS.Stop();
mx410.Stop();
f250.Stop();
fxs.Turn("left");
modelS.Turn("right");
mx410.Turn("left");
f250.Turn("right");
}
}
}