The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
JAVA Program
Maintain customer data (binary file)
Console
Welcome to the Customer Maintenance application
COMMAND MENU
list - List all customers
add - Add a customer
upd - Update customer data
del - Delete a customer
help - Show this menu
exit - Exit this application
Enter a command: list
CUSTOMER LIST
frank46@hotmail.com Frank Jones
sarah_smith@yahoo.com Sarah Smith
Enter a command: add
Enter customer email address: test@gmail.com
Enter first name: text
Enter last name: test
text test was added to the database.
Enter a command: list
CUSTOMER LIST
frank46@hotmail.com Frank Jones
sarah_smith@yahoo.com Sarah Smith
test@gmail.com text test
Enter a command: upd
Enter customer email address of a current record: test@gmail.com
Enter first name: Waldo
Enter last name: Pepper
Enter a command: list
CUSTOMER LIST
frank46@hotmail.com Frank Jones
sarah_smith@yahoo.com Sarah Smith
test@gmail.com Waldo Pepper
Enter a command: del
Enter customer email to delete: test@gmail.com
Waldo Pepper was deleted from the database.
Enter a command: list
CUSTOMER LIST
frank46@hotmail.com Frank Jones
sarah_smith@yahoo.com Sarah Smith
Enter a command: exit
Bye.
Operation
This application begins by displaying a menu with six choices: list, add, upd, del, help, and exit.
If the user enters “list”, the application displays the customer data that’s stored in a binary file.
If the user enters “add”, the application prompts the user to enter data for a customer and saves that data to the binary file.
If the user enters “upd” the application prompts the user to enter the email address. Then, it lets the user update the first name or last name for the customer. This data is stored in the binary file.
If the user enters “del”, the application prompts the user for an email address and deletes the corresponding customer from the binary file.
If the user enters “help”, the application displays the menu again.
If the user enters “exit”, the application displays a goodbye message and exits.
Specifications
Create a class named Customer that stores data for the user’s email address, first name, and last name.
Create interfaces named CustomerReader and CustomerWriter that define the methods that will be used to read and write customer data to a customer file. In addition, create an interface named CustomerConstants that contains three constants that specify the display size of a customer’s email address (30), first name (15), and last name (15). Then, create an interface named CustomerDAO that inherits all three of these interfaces.
Create a class named CustomerRandomFile to store the data in a random-access file named customer.ran in the same directory as this class. This class should use the seek method to randomly access each customer record whenever that’s necessary. If the customers.dat file doesn’t exist, this class should create it.
Create a class named DAOFactory that contains a method named getCustomerDAO. This method should return an instance of the CustomerRandomFile class.
Create a CustomerMaintApp class that displays the prompts shown in the console output and accepts the user entries. This class should use the DAOFactory class to get a CustomerDAO object. Then, it should use the methods of the CustomerDAO object to read customer data from the file and to write customer data to the file.
Use the Validator class or a variation of it to validate the user’s entries. Non-empty strings are required for the email address, first name, and last name.
Use spaces to align the customer data in columns on the console. To do that, you can create a utility class named StringUtils with a method that adds the necessary spaces to a string to reach a specified length.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------sol-----------uti-----------on.-----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- ca-----------tch-----------