Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a subclass Create a sub class that inherits everything from your base class. (For example, if Car is the base class then SportsCar

image text in transcribed

1. Create a subclass Create a sub class that inherits everything from your base class. (For example, if Car is the base class then SportsCar could be your sub class) [1 point] Provide at least one additional attribute to your subclass [1 point] Create a default constructor for the subclass, that uses super to call the base class default constructor. [1 point] Create a parameterized constructor for the subclass, that uses keyword super to pass the inherited parameters to the base class. [1 point Override the display0 method to print out all the instance variable values from the base class, and also from the sub class. [1 point] o Create gettter/setter methods for it. lt should set all attributes in the subclass as well as the super class to default values It should set all attributes in the subclass as well as the super class to the values that are passed in to the constructor It should also have a method called toString and printToFile (see instructions in part 2 below) 2. Create an Interface Create an interface called Printable that has the following methods declared: display0, printToFile0 and toString0 Make your subclass above implement the interface. This includes writing the bodies of all 3 methods. You should already have a display method, so you need to implement the other 2 methods [1 point] Override the toString method in the subclass in part 1 [1 point] .Implement the print ToFile method in the subclass in part 1. The method should be able to append to a file, not overwrite it. [1 point 3. Update main method In your main method, create 2 new object using your subclass . Create one object using the no-arg (default) constructor of your sub-class. [1 point] Create one object using the parameterized constructor of your sub-class. [1 point] Loop (iterate) through each object calling the print ToFile method. [1 point] o Call the set methods to set all attribute data associated to that object. o Create an ArrayList of all your objects, including the original ones created using the Super class and the new ones created using the Base class. [1 point] o

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions

Question

Did you cite the sources of the statistics?

Answered: 1 week ago