Created
January 28, 2020 06:59
-
-
Save einnar82/f5caefd209978a4948cb335e380adf18 to your computer and use it in GitHub Desktop.
Superclass vs Subclass part 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MountainBike extends Bicycle { | |
// Now, the Bicycle class is the SUPERCLASS and the MountainBike class is the SUBCLASS | |
// the MountainBike subclass adds one field | |
public int seatHeight; | |
// the MountainBike subclass has one constructor | |
public MountainBike(int startHeight, | |
int startCadence, | |
int startSpeed, | |
int startGear) { | |
super(startCadence, startSpeed, startGear); | |
seatHeight = startHeight; | |
} | |
// the MountainBike subclass adds one method | |
public void setHeight(int newValue) { | |
seatHeight = newValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment