The FCIT Digital Store, which has reward plans for its loyal customers, sells movies, documentaries and series. Each of these digital items is sold for different prices.

The digital store provides its services to both registered and unregistered customers. Registration offers the benefit of accumulating reward points. For every order the system checks if the customer is registered or not. The store starts with a predefined database of customers [see input.txt]; there is no need to implement new registrations now. The unregistered customer will have an id (-999).

The digital store has age restriction on movies and series transactions. If the age of the customer is under 18 a custom exception (UnderAgeException) must be thrown by the program and a meaningful message is displayed to the user.

The program must automatically store all digital items (movies, documentaries and series) in an Array List called digitalItems:

ArrayList< Item> digitalItems = new ArrayList< >();

Also all customers' information should be stored in another arraylist called customerList:

ArrayList < Customer> customersList = new ArrayList< >();

A transaction consists of a single purchase. The digital store stores all the transaction details for orders executed by the store, including name and price of sold items, reward points and customer ID. If the transaction was for an unregistered customer, the customer ID in the record is "-999". For registered customers; if the transaction total cost is greater than 100, then the user will gain an extra 10 points, which will be added to his rewarded points.

This program contains a simple GUI that allows users (customers or staff) to display the rewarded points for specific customer.

The Initial Procedure of the Program

You will use File I/O to read input from a given input file [input.txt]. Make sure the file exists or display a message that the file does not exist.

The commands you will have to implement are as follows:

Add_Customer- Makes a new customer which is added to the customersList arraylist in the system. The command will be followed by the following information, ALL on the same line:

A String representing the first name of the customer; a String representing the last name of the customer; an int representing the customer id; an int representing the age of the customer; an int representing the current rewarded points. [see input.txt]

Add_Customer Ahmad Ali 12321 19 25

Note: Each customer record must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Add_Movie- Makes a new Movie item which is added to digitalItems arraylist in the system. The command will be followed by the following information, ALL on the same line:

A String representing the name of the movie and an int representing the price of the item. [see input.txt]

Add_Movie Braveheart 100

Note: Each movie record must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Add_Documentary- Makes a new Documentary item which is added to digitalItems arraylist in the system. The command will be followed by the following information, ALL on the same line:

A String representing the name of the documentary item and an int representing the price of the item. [see input.txt]

Add_Documentary What the Health 150

Note: Each documentary record must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Add_Series- Makes a new series item which is added to digitalItems arraylist in the system. The command will be followed by the following information, ALL on the same line:

A String representing the name of the series item, an int representing the price of the item and an int representing the season's number for the item. [see input.txt]

Add_Series Genius 50 1

Note: Each series record must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Order_Movie- Makes a new movie order. The command will be followed by the following information, ALL on the same line:

An int representing the transaction id, a String representing the name of the movie, and an int representing the customer id. [see input.txt]

Order_Movie 3572 Gandhi 12321

Note: You have to create a transaction and add to the transaction list of the specified customer.

Note: If there is an order for a movie and the age of the customer is less than 18, then an UnderAgeException object is thrown with an appropriate message.

Note: Each movie order must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Order_Documentary- Makes a new documentary order. The command will be followed by the following information, ALL on the same line:

An int representing the transaction id, a String representing the name of the documentary and an int representing the customer id. [see input.txt]

Order_Documentary 3291 Live and Let Live 12998

Note: You have to create a transaction and add to the transaction list of the specified customer.

Note: Each documentary order must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Order_Series- Makes a new series order. The command will be followed by the following information, ALL on the same line:

An int representing the transaction id, a String representing the name of the series, an int representing the customer id and an int representing its season. [see input.txt]

Order_Series 9872 The Pacific 14390 2

Note: You have to create a transaction and add to the transaction list of the specified customer.

Note: If there is an order for a series and the age of the customer is less than 18, then an UnderAgeException object is thrown with an appropriate message.

Note: Each series order must be saved in the Commands Output.txt file as per given sample Commands Output.txt file.

Print_Transactions- Your program must generate a report that contains all the customers' transactions and print it to the output file named All Transactions.txt [see All Transactions.txt].

Note: (using Collections.sort(arraylist))

  • You must sort the customers arraylist.
  • You must sort the transactions of each customer before print it.

Important program details:

  • You have to implement the Customer, Item, Movie, Documentary, Series and Transaction classes depending on the UML diagram.
  • The Customer class must implement the comparable interface and override the compareTo method in order to sort the customers according to their ids.
  • The Transaction class must implement the comparable interface and override the compareTo method in order to sort the transactions according to their ids.
  • Add a new Discountable interface which contains:
    • A constant discountRate = 0.2
    • An abstract method called calculateDisPrice
  • The Series class must implement the Discountable interface and implement the calculateDisPrice method in order to calculate the discounted price of the shake item using discountRate in Discountable interface.
  • In Customer class, the method addTransaction throws an UnderAgeException exception.
  • Add a new Custom Exception class and name it UnderAgeException. This class is a direct subclass of the Exception class.
  • If the transaction was for either a movie or a series and the customer's age was less than 18, then an UnderAgeException object is thrown with the message:
    • Exception: Sorry! Your are not allowed to watch this
  • Use try-catch block to handle this exception and to print the exception message to the file. [see Commands Output.txt]

Program Graphical User Interface

Figure: see image.

Implement your program using GUI which looks like the above figure. The GUI should appear in the center. Allow the customer to enter an ID number. Create event listeners for the buttons: Search, Clear and Exit.

Search button: based on the entered customer ID, an action will be triggered to search for the given customer ID in the customerList and return the customer name and his rewarded points to the appropriate JTextFields.

If the customer id was empty or not found in the customerList, show a dialog message (using JOptionPane) with a suitable message as below.

Figure: see image.

Exit button: implement the appropriate action to end the program.

Clear button: when press this button an action should be triggered to clear all the JTextFields in the GUI-interface.

Important Notes:

  • Use Abstract class, Interface and compareTo() as well as exception handling concept to solve this assignment.
  • Your program should output in a similar format to the sample run provided.
  • Make your code readable.
  • Document your code with comments.
  • Use meaningful variables.
  • Use dash lines between each method.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.