Question: Inheritance Stuff! Vehicle: This should be a new class with:attributes for: speed number of passengers get methods for both attributes set methods for both attributes

Inheritance Stuff!

Vehicle:

This should be a new class with:attributes for:

speed

number of passengers

get methods for both attributes

set methods for both attributes (make sure to verify that attributes won't be negative!)

a toString() method

a default constructor:

sets speed to 0

sets number of passengers to 0

a full parameter constructor:

Remember to verify that attributes aren't negative!

If an input parameter is negative, set to zero instead!

Auto:

Adjust Auto to be a child/derived class of Vehicle:

Adjust the class header

Change the Constructors to correctly use the super() call.

Change the toString() method to correctly generate a String with both Vehicle and Auto attribute information

Bicycle:

Adjust Bicycle to be a child/derived class of Vehicle:

Adjust the class header

Change the Constructors to correctly use the super() call.

Change the toString() method to correctly generate a String with both Vehicle and Bicycle attribute information

----------------------------------------------

File Stuff!

Use you driver to:

Create an ArrayList of Vehicle type

Create Scanner to read from the Vehicles.txt file

In your reading loop:

read a line from the file

break the line into parts using split()

Determine if the line has Auto data or Bicycle data (data element 0 on each line is either "Auto" or "Bicycle")

Build the Auto or Bicycle described by the data:

Data element 1 is the speed of the vehicle

Data element 2 is the number of passengers

Data element 3 is the serialnumber OR licenseplate data

Data element 4 is the permitStatus OR locked status

Generate Color or Brand yourself using the appropriate method call from the appropriate enum

Store the newly create Auto or Bicycle into your ArrayList of Vehicles

After all Vehicles have been created and stored in your ArrayList of Vehicles (Done reading the file), have another loop to print out the data from each Vehicle in your ArrayList (this should test/verify that your toString() changes worked!)

--------------------------------------------

Grading Breakdown:

Vehicle: 20 points

Auto Changes: 20 points

Bicycle Changes: 20 points

Reading from the File: 30 points

ArrayList stuff (10 points)

File I/O stuff (10 points)

split() stuff (10 points)

Printing out the Vehicles in separate loop: 10 points

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!