Question: 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

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!