Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I previously posted this however the response does not work. Please provide correct coding for this Java lab. Create a well-formed class called Vehicle. The

I previously posted this however the response does not work. Please provide correct coding for this 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

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago