Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Goal : This lab was designed to teach you more designing and writing classes. Use the same runner code below and associated comments to

Lab Goal : This lab was designed to teach you more designing and writing classes. Use the same runner code below and associated comments to create a Car class.
Lab Description : Write a Car class that will keep track of miles driven and when you need to change your oil.
Sample Runner Code :
Car c = new Car(9000,3000); //single constructor that takes in miles
//driven and when to change the oil
//assumes car has never had an oil change
//sets last oil change mileage to 0
System.out.println( c.timeForOilChange()); //checks if it is time to change oil
//returns true as 9000 is >=3000
//resets last oil change mileage to 0
c.addMiles(2000); //add 2000 miles to miles driven
System.out.println( c.timeForOilChange()); //checks if it is time to change oil
//car has driven 2000 miles since
//last oil change returns false
c.addMiles(2000); //add 2000 miles to miles driven
System.out.println( c.timeForOilChange()); //checks if it is time to change oil
//car has now driven 4000 miles since
//last oil change return true
//4000 is >=3000 so time to change oil
Sample Output :
true
false
true

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

Do you agree that unions stifle creativity? Why or why not?

Answered: 1 week ago

Question

6 What is the selection phase?

Answered: 1 week ago