Question

In: Computer Science

The purpose of this assignment is to have you become familiar with polymorphism and be able...

The purpose of this assignment is to have you become familiar with polymorphism and be able to design classes with inheritance

The purpose of this assignment is to have you become familiar with polymorphism and be able to design classes with inheritance. Task The School Library has many items available for its students; some can be checked out and others cannot. Among those that can be checked out are journal (i.e., a literary journal) and digital video disk (i.e., a DVD). These two types have many attributes in common such as title, publisher, and dewey decimal classification. Design a class to represent the library item that would capture the common features among journals and DVDs. Then, design journal and digital video classes that are derived from the library item base class.

The library item class does not need more attributes (you can use the ones provided if you like), but you should add at least 2 methods to the class. The journal and digital video classes should have at least 3 attributes and at least 2 methods.

I need a java code for this.

Solutions

Expert Solution

Program:

//class LibrayItem
class LibrayItem
{
   //attributes
   String title;
   String publisher;
  
   //method to set title
   public void setTitle(String title)
   {
       this.title = title;
   }
   //method to set publisher
   public void setPublisher(String publisher)
   {
       this.publisher = publisher;
   }
}


//class Journal
class Journal extends LibrayItem
{
   //attributes
   String editor;
   String subject;
   String id;
  
   //method to set editor
   public void setEditor(String editor)
   {
       this.editor = editor;
   }
  
   //method to set subject
   public void setSubject(String subject)
   {
       this.subject = subject;
   }
  
   //method to set id
   public void setId(String id)
   {
       this.id = id;
   }
}

//class Dvd
class Dvd extends LibrayItem
{
   //attributes  
   int size;
   String dvdNumber;
   String returnDate;
  
   //method to set size
   public void setSize(int size)
   {
       this.size = size;
   }
  
   //method to set dvdNumber
   public void setDvdNumber(String dvdNumber)
   {
       this.dvdNumber = dvdNumber;
   }
  
   //method to set returnDate
   public void setReturnDate(String returnDate)
   {
       this.returnDate = returnDate;
   }
}

N.B. Whether you face any problem then share with me in the comment section, I'll happy to help you. I expect positive feedback from your end.


Related Solutions

Purpose of Assignment The purpose of this assignment is to allow the students to become familiar...
Purpose of Assignment The purpose of this assignment is to allow the students to become familiar with and practice the measurement of Net Present Value (NPV), payback, and Weighted Average Cost of Capital (WACC) using Microsoft® Excel®. Assignment Steps Resources: Microsoft® Excel®, Capital Budgeting Decision Models Template Calculate the following problems using Microsoft® Excel®: Calculate the NPV for each project and determine which project should be accepted. Project A Project B Project C Project D Inital Outlay (105,000.000) (99,000.00) (110,000.00)...
Purpose of Assignment The purpose of this assignment is to allow the students to become familiar...
Purpose of Assignment The purpose of this assignment is to allow the students to become familiar with and practice the measurement of Net Present Value (NPV), payback, and Weighted Average Cost of Capital (WACC) using Microsoft Excel. Assignment Steps Resources: Microsoft® Excel®, Capital Budgeting Decision Models Template, Calculate the following problems using Microsoft® Excel®: Calculate the NPV for each project and determine which project should be accepted. Project A Project B Project C Project D Inital Outlay (105,000.000) (99,000.00) (110,000.00)...
Co-occurring Treatment and Recovery Chart The purpose of this assignment is to become familiar with the...
Co-occurring Treatment and Recovery Chart The purpose of this assignment is to become familiar with the treatment and recovery methods, modalities, and strategies. After reading all assigned material complete the “Co-occurring Treatment and Recovery Chart” by filling in the information for the following categories below. Description or definition of the strategy: What is the strategy and modality? For example, regarding stages of change, what is the brief definition of this method? Key concepts and brief definitions: What are the common...
Question Objective: The purpose of this lab is for you to become familiar with Python’s built-in...
Question Objective: The purpose of this lab is for you to become familiar with Python’s built-in text container -- class str -- and lists containing multiple strings. One of the advantages of the str class is that, to the programmer, strings in your code may be treated in a manner that is similar to how numbers are treated. Just like ints, floats, a string object (i.e., variable) may be initialized with a literal value or the contents of another string...
Question Objective: The purpose of this lab is for you to become familiar with Python’s built-in...
Question Objective: The purpose of this lab is for you to become familiar with Python’s built-in text container -- class str -- and lists containing multiple strings. One of the advantages of the str class is that, to the programmer, strings in your code may be treated in a manner that is similar to how numbers are treated. Just like ints, floats, a string object (i.e., variable) may be initialized with a literal value or the contents of another string...
The purpose of this lab is to become familiar with searching, inserting and deleting elements in...
The purpose of this lab is to become familiar with searching, inserting and deleting elements in a linked list.using java   public boolean contains(String name) // returns true if provided name exists in the list, otherwise returns false public void add(String name) // adds name to the list in its proper lexographical (alphabetical) ordering public void delete(String name) // removes name from list
Over the past few weeks, you have become more familiar with your staff and are beginning...
Over the past few weeks, you have become more familiar with your staff and are beginning to feel like part of their family. To that end, you have recently accepted some "friend requests" on Facebook from some of the staff. You were at home last night, getting caught up on Facebook when you came across a post from one of the employees that said: " I hate my new boss at the clinic. A power hungry jerk making too many...
You are required to become familiar with the workings of the Rat in a Maze program...
You are required to become familiar with the workings of the Rat in a Maze program and make certain adjustments to the program. To become familiar with the program I suggest that you run it several times, using a different maze and maybe a different food location. Also trace by hand to ensure you understand how each step works. The adjustments to be made are: 1. Allow the RAT to move in a diagonal direction, so now there are a...
The assignment will be in our current situation you are able to have fans in your...
The assignment will be in our current situation you are able to have fans in your arena/stadium at a 25% capacity. How with the current guidelines and social distancing do you pull this off. Questions: What is you plan for social distancing fans in the stands? Where would you place hand sanitizer? How will your parking lots look like? How will you scan tickets? How will concessions look like? How will you serve food/drinks? What will Leaving the Stadium Look...
The assignment will be in our current situation you are able to have fans in your...
The assignment will be in our current situation you are able to have fans in your arena/stadium at a 25% capacity. How with the current guidelines and social distancing do you pull this off. Questions: What is you plan for social distancing fans in the stands? Where would you place hand sanitizer? How will your parking lots look like? How will you scan tickets? How will concessions look like? How will you serve food/drinks? What will Leaving the Stadium Look...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT