-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
62 lines (51 loc) · 973 Bytes
/
Test.java
File metadata and controls
62 lines (51 loc) · 973 Bytes
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
class Bicycle
{
//Declaring data types
public int gear;
public int speed;
//dfining Constructor
public Bicycle(int gear,int speed)
{
this.gear = gear;
this.speed = speed;
}
//Defining two methods
public void applyBrake(int decrement)
{
speed = speed - decrement;
}
public void speedUp(int increment)
{
speed = speed + increment;
}
public String toString()
{
return("Number of gears are : " + gear + "\n" + "Speed of bicycle is : " + speed);
}
}
class MountainBike extends Bicycle
{
public int weight;
public MountainBike(int gear,int speed,int weight)
{
super(gear,speed);
this.weight=weight;
}
public void IncreasedWeight(int value)
{
weight = value;
}
@Override
public String toString()
{
return(super.toString() + "\nWeight of bicycle : " + weight);
}
}
public class Test
{
public static void main(String [] args)
{
MountainBike obj = new MountainBike(7,50,10);
System.out.println(obj.toString());
}
}