Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create Car class using information below Instance Variables private String carModel; // Car Model (e.g., Honda Civic) private double milesPerGallon; // Car's average mpg rating

Create Car class using information below

Instance Variables

private String carModel; // Car Model (e.g., "Honda Civic")

private double milesPerGallon; // Car's average mpg rating (e.g., 28.5)

private double gasTankSize; // Car's gas tank size, in gallons (e.g., 12.0)

private double gallonsInTank; // Gas (in gallons) remaining in gas tank (e.g., 9.2)

image text in transcribed

image text in transcribed

Car API Function parameters) Description Carl Default Constructor tankSize, double galLevel) String getCarModelO Returns a String representing the car model void Isett Car Modelstring m) Sets the cars model to m double getMilesPerGalon Returns a double representing the cars mog rating void setMilesPerGallon double mpg) Sets the cars miles-per-gallon rating to mpg double get GasTanksize() Returns a double representing the car's tank size in void setGasTanksize(double tankSize) Sets the car's tank size to tanksize (gallons) double allonslnTankl Returns a double representing the number of gallons in the car's tank. void setGallonslinTank(double galLevel Sets the car's tank level to galLevel. If galLevel is bigger than the tank size, then automa set the number of atical gallons in the tank to the tank size. drive Distance double miles) boolean Simulates the car driving some distance, represented by the miles parameter. This function will appropriately burn" the proper amount of gas in the tank. f there is enough gas to driv e a distance of miles, this function should print out how many gallons of fuel were just burnt AND how many more miles can be driven before running out of fuel. Return true to indicate a successful drive. f there is not enou g in the tank to drive a distance of miles without running out of fuel, the function should print out a statement indicating how many miles were traveled before running out of fuel. Return false to ndicate a failed drive. NOTE: See sample output for print formatting double filIT "Tops" off the tank by filling it to capacity. Prints to the Tank user how many gallons of fuel were added and how many miles they can travel on their full tank. Finally, return the number of gallons added as a double NOTE. See sample output for print formgtting. Car convertToHybrid() Creates a new car object with the same instance parameter variables, but adds the word ybrid" to the new car model and increases its miles-per-gallon rating by 10mpg. Returns the new car object. String toString) boolean equals(object o Returns true if ois a stance of a Car AND has the same exact values as all of the instance variables. Returns fal se otherwise

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions