Question: Create a Java project called BookStore, which is also your main class. The project additionally has the class Publication. Publication has two data members: genre,

Create a Java project called BookStore, which is also your main class. The project additionally has the class Publication. Publication has two data members: genre, a string to store the publications genre, and a string title to hold the publications title. The class has a constructor to initialize these two attributes. Publications are sorted based on genre first and then title. The class also has the method getinfo() which returns:, .

For example: Charlottes Web, Childrens Books.

Create the class Book. This class extends Publication. The class has also the data member author, a string to hold the books author name. The class has a constructor to initialize its data members. The class overrides Publications getInfo() to add the authors name, such as:

Charlottes Web, Childrens Books. Written by E. B. White

Create the class Magazine. This class extends Publication. The class has also the data member publisher, a string to hold the magazines publisher name. The class has a constructor to initialize its data members. It overrides Publications getInfo()to add the publishers name, such as:

Vogue, Lifestyle. Published by Conde Nast

Copy and paste the following code into your main method in BookStore. Do not modify it. ArrayList myBookStore = new ArrayList<>(); myBookStore.add(new Book("Patricia Churchland", "Consciousness", "Neurophilosophy")); myBookStore.add(new Magazine("Springer Nature", "Nature", "Science and Technology")); myBookStore.add(new Publication("Mastering the game of Go", "Science and Technology")); myBookStore.add(new Book("LazyTown", "On the Nature of Baking Cakes", "Cakeshop Philosophy")); Collections.sort(myBookStore); for(Publication p: myBookStore) System.out.println(p.getInfo());

The output should look like:

On the Nature of Baking Cakes, Cakeshop Philosophy. Written by LazyTown

Consciousness, Neurophilosophy. Written by Patricia Churchland

Mastering the game of Go, Science and Technology.

Nature, Science and Technology. Published by Springer Nature

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!