Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you modify this for me please? Modify your program from Assignment 3 that defined and tested a vehicle class with a single engine to

Can you modify this for me please?
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Modify your program from Assignment 3 that defined and tested a vehicle class with a single engine to represent either a electric engine vehicle or an internal combustion vehicle. Pay careful attention to changes within each individuall class The Vehicle class represents a single vehicle. For the purpose of this assignment, assume that each of these vehicles contains one of two engines: either an internal combustion or electric engine. The internalCombustionEngine class and ElectricEngine class are both subclasses of the Engine class The Vehicle class should contain: .An Engine data member named engine that contains an Engine instance (which can either be electric or internal combustion). .A String make that sets the make for the vehicle. This should default to Toyabu * A String modethat sets the model for the vehicle This should default to-prata" .A default no-arg constructor that creates a default Vehicle. Set your default values here by using the appropriate set methods .A constructor that allows the client to set the engine, vehicle make, and vehicle model e Accessor and mutator methods for all data members . A method named toString) that returns a String indicating the make, model, internal combustion engine's type and number of cylinders and/or electric engine's type and output rating. See sample output for the needed format The Engine class should contain .A String data member named type that indicates the type of engine. This should default to internal combustion .A default no-arg constructor that creates a defauilt Engine. Set your default values here by using calling the other constructor with the this keyword and the appropriate default values 71 kW for electric, 4 cylinders for internal combustion). .A constructor that allows the client to set the type of engine with a parameter Accessor and mutator methods for all data members. Mutators should check values as .A method named toString) that returns a String indicating the type of engine as a String The InternalCombustionEngine class is a subclass of Engine and should contain . An int data member named cylinders that indicates the number of cylinders. This should default to 4. In the mutator, make sure the value being set is not negative. If a negative value is passed in, set it to 4 .A default no-arg constructor that creates a default InternalCombustionEngine. Set your default values here by using calling the other constructor with the this keyword and the appropriate default values . A constructor that allows the client to set the cylinders with a parameter Accessor and mutator methods for all data members. Mutators should check values as described above. . A method named toStringo0 that returns a String indicating the type of engine and the number of cylinders as a String. Use the super keyword to get the type of engine. The ElectricEngine class is a subclass of Engine and should contain: . An int data member named outputRating that gives the rated output of an electric engine. This should default to 71In the mutator, make sure the value being set is not negative. If a negative value is passed in, set it to 71 A default no-arg constructor that creates a default Electr drgne. Set your default values *

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions