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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started