Students, please be sure to log in. This site does not use cookies and does not track/store work submitted when not signed in.
Unit 5 Problems
Java Reference Sheet
Bicycle
Objective(s): Be able to write the getters and setters of a Java class.
Write a Bicycle class. It should have two private instance variables gear and speed. A constructor should be provided that allows the creation of Bicycle objects with a given gear and speed through a line such as Bicycle b = new Bicycle(7, 15); Finally, include getters for all the instance variables as well as all setters.
Use the naming convention of getInstanceVarName and setInstanceVarName.
Recall the syntax for getters:
public type getVarName(){
return varName;
}
Recall the syntax for setters:
public void setVarName(type newVal){
varName = newVal;
}