Students, please be sure to log in. This site does not use cookies and cannot store work submitted when not signed in.

Unit 5 Problems

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;
}

Type your solution        
Skills Practiced:
3.B
4.A
4.B
Copyright © StudyCS 2024 All rights reserved.