Please read carefully and follow the instruction: Create the following classes. Use appropriate access modifiers (instance variables should be private!) and data types for each. Don’t forget to add getter and setter functions.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please read carefully and follow the instruction:

Create the following classes. Use appropriate access modifiers (instance variables should be private!) and data types for each. Don’t forget to add getter and setter functions.

  1. Item: This class has the attributes (member variables) called title, description, and price.
    • Book: This class inherits from Item Book extends Item. It has an instance variable called pageCount
    • Movie: This class inherits from Item. Movie extends Item. It has an instance variable called  length
    • CD: This class inherits from Item. CD extends Item. It has an instance variable called trackCount.

2.Write a class called Book that contains instance data for the title, description, price, pageCount and copyright date. Define the Book constructor to accept and initialize this data. Include setter and getter methods for all instance data. Override toString() method to returns a nicely formatted, multi-line description of the book.
3.Write another class called Bookshelf, which has a name and array of Book objects. Bookshelf capacity is maximum of five books (do not use an arrayList) . Includes method for Bookshelf that adds, removes, isFull( returns Boolean), isEmpty(returns Boolean) and toString() method that returns all information about the Books in the Bookshelf.
4. Create a driver class called TestProject, whose main method instantiates five Book objects, two Movie objects and two CD objects. Use a constant name, no need for scanner.

Example: 

Book b1 = new Book(“Java Book”,”Laing”,200.0,2016,”11-20-2020”);

Movie x = new Movie(“ET…”,”Et was from Jupiter”,6.0, 2);

CD      cd = new CD(“Best”,”Xcompany”,15.0, 120);

.5.Create an array of Item of size 9.

Item [] ar = new Item[9];

  1. Assign all nine objects created to this array.

7.Use the loop for each to print all element of the array ar.

for(Item aItem : ar)

    System.out.println(aItem);

8.Now you have nine objects in the array of ar. Five books, two Movies and two CDs.

9 Use the following loop:

for(int i=0; I < ar.lenght; i++)

{

     // try to add books from array ar to Bookshelf array.

    // print the book pageCount using getPageCount() method

    // print Movie length using getLength()

   // print CD trackCount using getTrackCount.

}

10 Print Bookshelf content

11 Now create a new book.

  Book aNew = new Book((“Java Book”,”Laing”,”Pearson”,200.0,2016);

 Add aNew book to the Bookshelf using its add method.

 The Bookshelf should print if there is a duplicate.

  1. at last print content of array ar.

Submit .java files only.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY