-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(Today)InterFace.cs
88 lines (70 loc) · 1.48 KB
/
(Today)InterFace.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
using System;
namespace ConsoleApp18
{
interface IVehicle
{
void ChangeGear(int a);
void SpeedUp(int a);
void ApplyBreakes(int a);
}
class Bycycle : IVehicle
{
int speed;
int gear;
public void ChangeGear(int newGear)
{
gear = newGear;
}
public void SpeedUp(int increment)
{
speed = speed+increment;
}
public void ApplyBreakes(int decrement)
{
speed = speed - decrement;
}
public void PrintStatus()
{
Console.WriteLine("Speed" + speed + " gear" + gear);
}
}
class Bike:IVehicle
{
private int speed;
private int gear;
public void ChangeGear(int newGear)
{
gear = newGear;
}
public void SpeedUp(int increment)
{
speed = speed + increment;
}
public void ApplyBreakes(int decrement)
{
speed = speed - decrement;
}
public void printState()
{
Console.WriteLine("speed" + speed + " gear" +gear);
}
}
public class Program
{
public static void Main(string[] args)
{
Bycycle bycycle = new Bycycle();
bycycle.ChangeGear(2);
bycycle.SpeedUp(3);
bycycle.ApplyBreakes(1);
Console.WriteLine("BiCycle Present state is : ");
bycycle.PrintStatus();
Bike bike = new Bike();
bike.ChangeGear(1);
bike.SpeedUp(4);
bike.ApplyBreakes(3);
Console.WriteLine("Bike Present state is : ");
bike.printState();
}
}
}