File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class Car {
2+
3+ public int gear ;
4+ public int speed ;
5+
6+ public Car (int gear , int speed )
7+ {
8+ this .gear = gear ;
9+ this .speed = speed ;
10+ }
11+
12+ public void applyBrake (int decrement )
13+ {
14+ speed -= decrement ;
15+ }
16+
17+ public void speedUp (int increment )
18+ {
19+ speed += increment ;
20+ }
21+ public String toString ()
22+ {
23+ return ("No. of gears are : " + gear + "\n " + "Speed of SuperCar is : " + speed + " mph" );
24+ }
25+ }
26+
27+ class SuperCar extends Car {
28+
29+ public int setHeight ;
30+ public SuperCar (int gear , int speed , int rideHeight )
31+
32+ {
33+ super (gear , speed );
34+ setHeight = rideHeight ;
35+ }
36+
37+ public void setHeight (int newValue )
38+ {
39+ setHeight = newValue ;
40+ }
41+ @ Override public String toString ()
42+ {
43+ return (super .toString () + "\n Ride height is : " + setHeight + " inch" );
44+ }
45+ }
46+ public class gears {
47+ public static void main (String [] args ) {
48+ SuperCar mb = new SuperCar (5 , 180 , 15 );
49+ System .out .println (mb .toString ());
50+ }
51+ }
52+
You can’t perform that action at this time.
0 commit comments