Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java programming 1) Create a class ReadingMaterial 2) Create a subclass of Readi

ID: 3808700 • Letter: J

Question

Java programming

1) Create a class ReadingMaterial

2) Create a subclass of ReadingMaterial called Newspaper - should call superclass

constructors

Be sure to include JavaDocs

----------------------------------------------------------------------------------------

using above UML please make java programming....

(these are my code I made little bit)

public class ReadingMaterial {

   /*

   * constructor for class ReadingMaterial

   */

   public ReadingMaterial(){

       System.out.println();

       System.out.println("ReadingMaterial constructor called");

   }

  

   /*

   * Display Method

   */

   public void display(){

       System.out.println("Display method of Reading Material is called");

   }

}

-----------------------------------------------------------------------------

public class Newspaper extends ReadingMaterial{

   /*

   * constructor for class Newspaper and class its parent class constructor

   */

public Newspaper(){

       super();

       System.out.println("News Paper constructor called");

       System.out.println();

   }

  

   /*

   * Display Method

   */

   public void display(){

       System.out.println("Display method of NewsPaper is called");

   }

-----------------------------------------------------------------------------------

ReadingMaterial language String publisher: String ReadingMaterial (publisher: String, language:String) getLanguage (void): String setLanguage (String) void getPublisher(void): String SetPublisher (String): void toString(): String Newspaper name: String size: Rectangle |numPages int NewsPaper publisher: string, tring, size:Rectangle, numPages:int) getName(): String getSize() Rectangle getNumPages(): int setName (String) void setSize(Rectangle) void setNumPages (int) void toString String Shouild never be instantiated Set default for language Default: English ReadingMaterial

Explanation / Answer

Java Program:

//Abstract class ReadingMaterial which makes the class can't be instantiated
abstract class ReadingMaterial
{
   //Instance variables
   private String language;
   private String publisher;
  
   //Constructor
   public ReadingMaterial(String publisher)
   {
       this.publisher = publisher;
      
       //Default Value
       this.language = "English";
   }
  
   //Getter method for language
   public String getLanguage()
   {
       //Returning language
       return this.language;
   }
  
   //Getter method for publisher
   public String getPublisher()
   {
       //Returning publisher
       return this.publisher;
   }
  
   //Setter method for language
   public void setLanguage(String language)
   {
       //Setting language
       this.language = language;
   }
  
   //Setter method for publisher
   public void setPublisher(String publisher)
   {
       //Setting publisher
       this.publisher = publisher;
   }
  
   //Overriding toString method
   public String toString()
   {
       return " Publisher: " + getPublisher() + " Language: " + getLanguage();
   }
}

//NewsPaper Class definition
class NewsPaper extends ReadingMaterial
{
   //Instance variables
   private String name;
   private Rectangle size;
   private int numPages;
  
   //Constructor
   public NewsPaper(String publisher, String name, Rectangle size, int numPages)
   {
       //Calling super class constructor
       super(publisher);
      
       this.name = name;
       this.size = size;
       this.numPages = numPages;
   }
  
   //Getter method for name
   public String getName()
   {
       //Returning name
       return this.name;
   }
  
   //Getter method for size
   public Rectangle getSize()
   {
       //Returning size
       return this.size;
   }
  
   //Getter method for number of pages
   public int getNumPages()
   {
       //Returning number of pages
       return this.numPages;
   }
  
   //Setter method for name
   public void setName(String name)
   {
       //Setting name
       this.name = name;
   }
  
   //Setter method for size
   public void setSize(Rectangle size)
   {
       //Setting size
       this.size = size;
   }
  
   //Setter method for number of pages
   public void setNumPages(int numPages)
   {
       //Setting numPages
       this.numPages = numPages;
   }
  
   //Overriding toString method
   public String toString()
   {
       return " Name: " + getName() + " Size: " + getSize() + " Number of Pages: " + getNumPages() + super.toString();
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote