You are the till attendant at a department store. At the start of the day your computer will read from file the customers database and store the customer’s details in memory. Then, during the day a series of customers will join a queue. Some will be new customers who must be added to the database. The others will want either to buy something or put money into their account. After such a transaction their account details will need to be updated. At the end of the day the system will write the new database to a file. Each customer has a title and a name (so that u can address him or her with a polite personal message and wish him or her a “nice day?? when he or she lives), an account number and a balance. The database is a series of such customers. The name is a string, the account number and the balance are integers. The database consists of a series of such customers, each detail on a separate line, e.g a typical file might look something like the following:-
The account number is always on the third line with the balance on the fourth. You may assume that no customer is allowed, or would ask for, credit, i.e all account balances will always be positive. The day’s actions will be kept in a separate file. The first line of each entry in this file will be a string, either **join** or **transact**. If it is **join** then the customer will join the back of the queue. The second line in this case will be the customer’s title and the third line will be his/her name. If the first line is **transact** the customer will either be paying money into his store account or buying an item. The second line will be either the string **buy** or **pay**. In either case the third line will be the amount of money which needs to be added or subtracted from their account. Note that you will not be given the name or account number for a transaction, it will simply be the first person in the queue. You must print to screen the details of the day trading. If a customer joins the queue you must report their title and name, i.e “[url removed, login to view] has joined the queue??. If there is a transaction you must say e.g “Good day Lady Thatcher??.
First of all write the code for a **Customer** class. It will need features for the name, title, et.c. These should all be declared as private. You will need methods for returning these features and a **constructor** which will take as an parameter list all the details read from the file. You will also need methods to add and subtract from their account. Save this file as **[url removed, login to view]**(remember case sensitivity). Next consider the database class. How you store the data is up to you, consider an array or a list and look up on **[url removed, login to view]** web-site how to use these classes. You will need features to construct the database (there will of course only be one), how to add a customer in the database, how to search tha database for a customer’s name, balance and title and how to rewrite the database to a file at the end of the day. This file will be called **Database.java.** Again you must consider security and code hiding. The next task is to write a **Queue** class. You will need to consider storage, adding to the back, getting information from the front person, removing the front person, etc. Finally u should write the **Store** class which will contain the **main** method and run the program**.** This will need to read the database, construct **Customer** objects and add them to the **Database** object. It will then read the transaction file one piece at a time, reporting on the state of the queue or transaction. It will update the queue for each action, and update customer’s records where necessary. When the file is finished and the query is empty it will report “Closing time?? and rewrite the database.
Accurate reporting of the state of the queue and a correct final database is what is required here.
Write, save and test each class separately. You should write a separate testing class for each class as you write it. Make sure that you test each class as you write it and do NOT wait until the whole program is written before debugging. You will need to write your own test data. I will be testing it using my own files, therefore you must pay attention to all possible inputs. You may assume that the queue will only be empty at the start and end of the program. There will be no trick data. Customers will not attempt to carry out a transaction unless they are in the queue, there will be no negative balances, and all customers who join the queue will have an account.
is the **Queue** class. Call the new file P_queue.java.