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.
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java...
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java application. Given a set of events, choose the resulting programming actions. Understand the principles behind Java. Understand the basic principles of object-oriented programming including classes and inheritance. Deliverables .java files as requested below. Requirements Create all the panels. Create the navigation between them. Start navigation via the intro screen. The user makes a confirmation to enter the main panel. The user goes to the...
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...
Write a Java application that implements the following: Create an abstract class called GameTester. The GameTester...
Write a Java application that implements the following: Create an abstract class called GameTester. The GameTester class includes a name for the game tester and a boolean value representing the status (full-time, part-time). Include an abstract method to determine the salary, with full-time game testers getting a base salary of $3000 and part-time game testers getting $20 per hour. Create two subclasses called FullTimeGameTester, PartTimeGameTester. Create a console application that demonstrates how to create objects of both subclasses. Allow the...
It is required to develop an application in Java to perform some operations of a bank....
It is required to develop an application in Java to perform some operations of a bank. The application will have the following classes: Class called Person having following data fields (private): firstName (String), lastName(String), gender(char), cpr(long), mobile(String) and following methods: Constructor having 5 parameters to initialize all data fields, Set and get methods for all data fields, toString method to return String equivalent of all data fields, Abstract class called Account having following data fields(protected): accountHolder(Person), ccountNum(long), balance(double)and following methods:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT