Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are going to adapt your code to use an inner static class that can return instance information from its container class. a. Change your

You are going to adapt your code to use an inner static class that can return instance information from its container class.

a. Change your Engine declaration to match the following:

public static class Engine extends Vehicle {

b. Create a constructor that accepts a String parameter named model.

c. The constructor should have a single instruction that send the model variable to the super constructor.

d. Go to your main method and create an Engine object named vehicle3 above the line of code that displays the total number of cars manufactured. To do this you will need to follow these guidelines:

Outerclass.InnerClass object name = new Outerclass.InnerClass (parameter);

Vehicle.Engine vehicle3 = new Vehicle.Engine("Fortune");

e. This gives you access to both the methods and fields of the inner class as well any methods and fields in its

enclosing class. Create an output statement that will use the appropriate getter methods to display the

following:

Vehicle number ch3 is a Fortune model and has an engine capacity of 1600cc

f. To see the difference between the different types of vehicles try to create the previous statement using vehicle1 or vehicle2 (it wont work as they dont have access to the inner workings of the static Engine class).

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

passionate about her work?

Answered: 1 week ago