In this task, you are required to provide complete class definitions and then create instances of various

In this task, you are required to provide complete class definitions and then create instances of various classes and use methods to perform various tests.

(a) Define an abstract class called Textbook with the following fields and methods:

Fields: title, author, pages representing the title, author and the number of pages of a textbook for a given book respectively. Encapsulation should be used to protect these fields against intentional or accidental, direct modification
Constructors: a no-args default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created
Methods: a toString() method to print a string representation of the objects, get and set methods to provide access to each of the three fields
(b) Define a subclass of the Textbook class called ProgrammingTextbook with the following additional field and methods:

Field: language representing the particular language the programming textbook uses. Again, encapsulation should be used to protect this field against intentional or accidental, direct modification
Constructors: a no-args default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created
Methods: a toString() method to print a string representation of the objects, additional get and set methods as required to provide access to the field
(c) Define another subclass of the Textbook class called EngineeringTextbook with the following additional field and methods:

Field: subject representing the particular engineering subject the textbook teaches. Again, encapsulation should be used to protect this field against intentional or accidental, direct modification
Constructors: a no-args default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created
Methods: a toString() method to print a string representation of the objects, additional get and set methods as required to provide access to the field
(d) Finally, define another class called TestTextbooks with a main() method to perform necessary testing for the classes defined in the previous sections. In the main method, write the code to create at least four objects of the ProgrammingTextbook class and at least four other objects of the EngineeringTextbook class. Create an ArrayList object to store references to these objects and then test various methods (e.g., constructors, set/get methods) including toString() method of the objects using loop(s) and methods as necessary.

Ensure that the program is appropriately documented throughout and thoro

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?