Question

In: Computer Science

Develop a Java application which implements an application for a store chain that has three types...

Develop a Java application which implements an application for a store chain that has three types of stores which are Book, Music, and Movie stores.

Your application should have an Item abstract class which should be extended by the Book and Multimedia classes. Item class has abstract priceAfterTax method, you need to implement this method in derived classes. Multimedia class is a superclass for Music and Movie classes. Your project should also include the IPromotion interface, which should be implemented by Book and Movie classes. Also, your application should have the Lookup class (which is provided in part in this document). Lookup class works as the datastore: it contains all the various items available - books, movies, music items - as well as the list of users.

In your main class you should initiate a lookup object in the main method. You also need to include a User class which has the fields and the methods shown for that class in the class diagram. User class has a library of items; once a user downloads or purchases any item, you should add this item to that user’s library. If the user just plays music or watches a movie you should not add this item to the user’s library.

Solutions

Expert Solution

abstract class Item

{

private String name;

private double price;

private double taxInPercentage;

public abstract double priceAfterTax();

public void download(User user)

{

user.library.add(this);

}

public static double totalPrice()

{

return price+((price)*taxi percentage)/100)

}

public String toString()

{

return "Name = "+name +"\t priceIncludingTax"+totalPrice();

}

}

interface Ipromotion

{

}

class Book extends Item implements Ipromotion

{

public Book(String name,double price,double taxInPercentage)

{

this.name= name;

this.price=price;

this.taxInPercentage=taxInPercentage;

}

public double priceAfterTax()

{

return totalPrice()

}

public Item download()

{

return this;

}

}

class Multimedia extends Item

{

public void play()

{

}

}

class Music extends Multimedia

{

public Book(String name,double price,double taxInPercentage)

{

this.name =name;

this.price=price;

this.taxInPercentage=taxInPercentage;

}

public double priceAfterTax()

{

return totalPrice()

}

}

class Movie extends Multimedia implements Ipromotion

{

public Book(String name,double price,double taxInPercentage)

{

this.name=name;

this.price=price;

this.taxInPercentage=taxInPercentage;

}

public double priceAfterTax()

{

return totalPrice()

}

}

class Lookup

{

public List<Book> books= new ArrayList<Book>();

books.add(new Book("Book1"),100,10));

books.add(new Book("Book2"),100,10));

public List<Movie> movies= new ArrayList<Movie>();

movies.add(new Movie("Movie1"),100,10));

movies.add(new Movie("Movie2"),100,10));

public List<Music> music= new ArrayList<Music>();

music.add(new Music("Music1"),100,10));

music.add(new Music("Music2"),100,10));

}

public class User

{

public static void main(String[] args) throws Exception

{

public List<Item> library= new ArrayList<Item>();

Lookup lookup = new Lookup();

lookup.books.get("Book1").download(this);

lookup.movies.get("Movie2").play();

lookup.music.get("Music1"). download (this);

System.out.println(library);

}

}


Related Solutions

Eclipse Exercise 1 Write a Java application that implements different types of insurance policies for employees...
Eclipse Exercise 1 Write a Java application that implements different types of insurance policies for employees of an organization. Let Insurance be an abstract superclass and Health and Life two of its subclasses that describe respectively health insurance and life insurance. The Insurance class defines an instance variable of type String to describe the type of insurance and an instance variable of type double to hold the monthly cost of that insurance. Implement the get methods for both variables of...
Develop a Java application that determines the gross pay for each of three employees.
(Salary Calculator) Develop a Java application that determines the gross pay for each of three employees. The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. You’re given a list of the employees, their number of hours worked last week and their hourly rates. Your program should input this information for each employee, then determine and display the employee’s gross pay. Use class...
Write a java application that implements ArrayStack in chapter 16 of your textbook.
Write a java application that implements ArrayStack in chapter 16 of your textbook. Your application should have two files: 1. ArrayStack.java: This file will have the implementation of your stack. 2. TestStack.java: This file will have the main method where you declare your stack object and test the different stack operations. In addition to the ArrayStack methods given in the book, you are to write a toString method. This will allow you to print the Stack object from main. You...
Develop a JavaFX GUI application called Registration that implements a user interface for registering for a...
Develop a JavaFX GUI application called Registration that implements a user interface for registering for a web site. The application should have labeled text fields for the Full Name, User Name, Password, Student Id, and a TextAreafor About Me. Include a button labeled Send. When the Send button is clicked, your program should print the contents of all fields (with labels) to standard output using println()statements.
Create a Java Application that implements a Selection sort algorithm to sort an array of 20...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20 unsorted numbers. You should initiate this array yourself and first output the array in its original order, then output the array after it has been sorted by the selection sort algorithm. Create a second Java Application that implements an Insertion sort algorithm to sort the same array. Again, output the array in its original order, then output the array after it has been sorted...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20 unsorted numbers. You should initiate this array yourself and first output the array in its original order, then output the array after it has been sorted by the selection sort algorithm.
USING JAVA and NOTTT using BufferedReader or BufferedWriter Write an application that implements a simple text...
USING JAVA and NOTTT using BufferedReader or BufferedWriter Write an application that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in a TextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the text in the original file. Hint: Read each line from...
Develop and test two Java classes: an array-based stack ADT that implements the provided StackInterface.java a...
Develop and test two Java classes: an array-based stack ADT that implements the provided StackInterface.java a linked list-based queue ADT that implements the provided QueueInterface.java You may not make any changes to StackInterface.java or QueueInterface.java The classes must be generic The attached generic singly linked list node class, LLNode.java, must be used for the queue implementation; you may not make any modifications to this class Your implementations cannot throw any exceptions Each ADT must include a toString( ) method: The...
Develop a Java application to simulate a game played in an elementary classroom. In this game,...
Develop a Java application to simulate a game played in an elementary classroom. In this game, the teacher places herself in the center of a circle of students surrounding her. She then distributes an even number of pieces of candy to each student. Not all students will necessarily receive the same number of pieces; however, the number of pieces of candy for each student is even and positive. When the teacher blows a whistle, each student takes half of his...
Develop a Java application that plays a "guess the number" game as described below. a) The...
Develop a Java application that plays a "guess the number" game as described below. a) The user interface is displayed and the user clicks the “Start Game” button to begin the game. b) Your application then gets a random number in the range 1-1000 inclusive (you might want to use Math.random or the Random class). c) The application then displays the following prompt (probably via a JLabel): I have a number between 1 and 1000 can you guess my number?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT