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]; 6. Assign all nine objects created to this array. 7.Use the loop for each to print all element of the array ar. for(Item altem: ar) System.out.println(altem); 8.Now you have nine objects in the array of ar. Five books, two Movies and two CDs.

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
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];
6. Assign all nine objects created to this array.
7.Use the loop for each to print all element of the array ar.
for (Item altem : ar)
System.out.println(altem);
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 a New book to the Bookshelf using its add method.
The Bookshelf should print if there is a duplicate.
12. at last print content of array ar.
Submit .java files only.
Transcribed Image Text: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]; 6. Assign all nine objects created to this array. 7.Use the loop for each to print all element of the array ar. for (Item altem : ar) System.out.println(altem); 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 a New book to the Bookshelf using its add method. The Bookshelf should print if there is a duplicate. 12. at last print content of array ar. Submit .java files only.
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.
o Book: This class inherits from Item Book extends Item. It has an instance variable called pageCount
o Movie: This class inherits from Item. Movie extends Item. It has an instance variable called length
o 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 Test Project, 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];
6. Assign all nine objects created to this array.
7.Use the loop for each to print all element of the array ar.
for (Item altem : ar)
System.out.println(altem);
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.
Transcribed Image Text: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. o Book: This class inherits from Item Book extends Item. It has an instance variable called pageCount o Movie: This class inherits from Item. Movie extends Item. It has an instance variable called length o 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 Test Project, 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]; 6. Assign all nine objects created to this array. 7.Use the loop for each to print all element of the array ar. for (Item altem : ar) System.out.println(altem); 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
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