Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions

Question

Does it avoid use of underlining?

Answered: 1 week ago