Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program public class Car public static void main(String) args) Car car new Car ) car.driveForward (Sacramento,100) car.park) car.driveForward (Davis,15) car.parko void driveForward

Write a Java program

image text in transcribed

public class Car public static void main(String) args) Car car new Car ) car.driveForward ("Sacramento",100) car.park) car.driveForward ("Davis,15) car.parko void driveForward (String towhere, int miles) System.out.printin ("Driving to " + towhere + " miles+"miles away") void parkO System.out.printin ("Parking the car") 1.Add a constructor that sets the type of car, a name for the car, and its initial location (and also sets the following defaults: that the car is parked; 2.Track where the car is, how far it has been driven, whether it is parked 3.Override toString to return ALL stored information about the car 4.Extras 1.Set how much fuel is in the car and how many miles per gallon it gets; then use fuel while you drive and add a method to fill the car with gas. 2.Instantiate a couple cars and track them in a static ArrayList of Cars

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions