Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 Write a MotorCycle class with the following attributes: ( efficiency ) measured in miles / gallon ( double ) ( tank ) capacity
Question
Write a MotorCycle class with the following attributes:
efficiency measured in milesgallon double
tank capacity measured in gallons double
Your class should include the following methods:
setEfficiency: sets the efficiency of the cycle
getEfficiency: gets the efficiency of the cycle
setTank: sets the amount of gas in the cycle
gettank: gets the amount of gas in the cycle
Launch External Tool
addGas: this method adds gas to the tank
drive: this method simulates driving the cycle for a certain distance in miles reducing the fuel level in the gas tank. Hint: MPG
Your class should not include a constructor and MUST use the default constructor.
To test your class you will need to instantiate a MotorCycle object myCycle in the MotorCycleDemo class.
You are required to implement the class according to the requirements specified in the comments displayed in CodeCheck.
Launch External Tool
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started