-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
72 lines (58 loc) · 1.59 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
using System;
namespace Inheritance
{
public class Vehicle
{
public string MainColor { get; set; }
public int MaximumOccupancy { get; set; }
public virtual void Drive()
{
Console.WriteLine("Vroom!");
}
}
public class Zero : Vehicle
{ // Electric motorcycle
public double BatteryKWh { get; set; }
public void ChargeBattery() { }
public override void Drive()
{
Console.WriteLine("Zooooooooom!!");
}
}
public class Cessna : Vehicle
{ // Propellor light aircraft
public double FuelCapacity { get; set; }
//override
public virtual void RefuelTank() { }
}
public class Tesla : Vehicle
{ // Electric car
public double BatteryKWh { get; set; }
public void ChargeBattery() { }
public override void Drive()
{
Console.WriteLine("zzzzZZZZZZzzzzzz");
}
}
public class Ram : Vehicle
{ // Gas powered truck
public double FuelCapacity { get; set; }
public void RefuelTank() { }
}
class Program
{
static void Main(string[] args)
{
var zero = new Zero();
var tesla = new Tesla();
var cessna = new Cessna();
var ram = new Ram();
zero.MainColor = "White";
tesla.MaximumOccupancy = 5;
zero.Drive();
tesla.Drive();
cessna.Drive();
ram.Drive();
}
}
}