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))
Important program details:
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: