Question: Java Lab Create a well-formed class called Vehicle. The class attributes (instance variables) are: brand , String type , String (gasoline, hybrid, electric) number of

Java Lab

Create a well-formed class called Vehicle.

The class attributes (instance variables) are: brand, String type, String (gasoline, hybrid, electric) number of doors, int price, double

As in all well-formed or fully formed classes, the Vehicle class should have default constructor and a full-argument constructor that receives the data in the args list.

In the default constructor set the brand value to Ford, set they type to gasoline, set the number of doors to 2, and set the price to $21,345.55.

Include typical methods: mutators (set), accessors (get), and a toString.

Include the following edits in the set methods (see Video lectures). The text sometimes puts edits in the constructors but for this course all edits go in the set methods.

Number of doors must be 2 or 4.

Price must be greater than or equal to 0.

Create a second class called VehicleTester.

Create a default vehicle object.

Invoke and print its toString

Create a second vehicle object using the full-arg constructor with these attributes:

brand: Chevrolet

type: hybrid

number of doors: 4

price: $36,995.99

Invoke and print the second vehicles toString

Create a third vehicle object using the default constructor.

Invoke and print the third vehicles toString.

Using the set methods mutate the third vehicles attributes to:

brand: Tesla

type: electric

price: $54,590.11

no mutation needed for number of doors.

Invoke and print the third vehicles toString a second time to view the changes

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!