Assignment title: Information
Objectives
The purpose of this assignment is to assess your competency in networking protocols, thread programming and database access.
Assessment task
Your task for this assignment is to design, implement, test and document a client/server system to solve the data persistence and retrieval problem. A distributed system often has a backend database for storing and retrieving business data. In this assignment, you are to implement a multiple-threaded client/server framework of an online Restaurant with backend database access ability.
The users accessing the online restaurant should able to view listing of three categories of menu items and these are:
• Beverage List
• Lunch Menu List
• Dessert List
•
The query frontend provides a menu to let a user choose any of these functions continuously until the user chooses to exit the system. Once it accepts a request, it will send the request to the server.
The server parses the client request and processes it to send reply to the client. Multiple users should be simultaneously able to view listings. The server creates a new thread for each connection (thread-per-connection model).
The details of different categories of menu item listing should be stored in three different database tables. The server thread queries the database tables to send reply to the client request.
The data required for the assignment are given in the file AssignData.csv. Please refer to example source code given in RestaurentServer folder to access database
Programmatically, use prepared statements to insert and query database.
Data Structures
You may follow the following class design.
• FoodMenu class
To store and manipulate the details read from the given file including foodType, itemName, protein, carbohydrate, sugar and energy.
• DatabaseUtility class
This class will have necessary data structures and methods to create the database and the Tables of Beverage, Lunch, and Dessert, populate the tables, and extract data from the tables. Use Prepared Statements to populate the tables using values loaded from the file. Also use Prepared Statements to extract data and store in appropriate data structure.
• RestaurantServer class
This class will have necessary data structures and methods to create the sockets for client connection, creating threads for each client. This class will have main() method to invoke methods from other classes to run the application.
• RestaurantClient class
This will take the user input, create socket and request connection to the server. This class will also send/receive the messages between the client/server.
Sample Output
Example screen shots from sample run of the application is given below
Welcome to Online Restaurant
Available Food Menus
1. Beverage
2. Lunch
3. Dessert
Enter a number to view full listing of Menu items
: 1
Display for Client One
Item Name Food Type Protein Carb (g) sugar energy
Chai latte regular fat cows milk Beverage 4 12.2 10.7 407
Chai latte reduced fat cows milk Beverage 4.4 11.5 10 329
Coffee white with regular fat cows milk Beverage 3.2 5.5 5.4 263
Coffee cappuccino with regular fat cows milk Beverage 2.6 5 4.8 221
Coffee cappuccino s with skim cows milk Beverage 2.7 4 4 116
Coffee flat white or latte with regular fat cows milk Beverage 2.7 4.8 4.8 228
Coffee flat white or latte with skim cows milk Beverage 2.9 3.9 3.9 116
Fruit drink apple juice commercial Beverage 0.1 10.9 10.9 178
Fruit drink orange juice commercial Beverage 0.2 10.4 10.4 176
Juice carrot home squeezed Beverage 0.8 5 5 133
Juice lemon home squeezed Beverage 0.6 1.8 1.8 115
Juice tomato commercial added salt Beverage 0.7 3.3 2.3 76
Juice grape commercial Beverage 0.2 13.4 13.4 221
Mineral water natural plain or unflavoured Beverage 0 0 0 0
Milk cow flavoured chocolate regular fat Beverage 3.6 0 8.8 338
Milk goat fluid regular fat Beverage 3.1 0 3.6 207
A typical display on server side is shown below.
Request Received from Client 1 on
Thread 0
Thread Id 9
Welcome Message sent to Client 1
Beverage Menu listing request received from Client 1. Beverage listing sent to Client 1.
Similarly messages will be displayed when more clients connect to the server.
Note: For your testing purposes using multiple clients run the RestaurantClient application from multiple JVM.
Report
Prepare a report that includes a diagrammatic representation of the system architecture, a test plan, and user insctructions.
Software Tools for Building the Application
You can use TexPad or NetBeans to develop your application. You have to install MySql server and configure to work within NetBeans and use the java program to create database, populate and query database.
Follow incremental building of application. Test the programmatic operation of database before creating multiple threads.
References and Source Code Files.
Use this for installing and setting up the MySql server.
Assignment Submission
You should submit the following source code files using the Moodle online submission system as one zip file (Note: the file names/class names could be changed to meaningful names).
• FoodMenu.java – Source code for the FoodMenu class
• RestaurantServer.java – Source code for the RestaurantServer class
• RestaurantClient.java – Source code for Client class
• DatabaseUtility.java – Source code for database creation and access
• Report.doc – word document containing the report as given above.
Assessment Marking criteria
S.No
Total Marks - 35
Marks
Allocated
Marks
Scored
1
The RestaurantClient class enabling send/receive of messages and appropriate handling of user input, proper formatting and display of user outputs
6
2
The RestaurantServer class enabling acceptance of client request, creation of thread per client which processes and responds to client request.
8
3
DatabaseUtility class enabling creation of database and tables, populating database tables with data from file, and extraction of data as requested by the client.
5
4
FoodMenu class enabling the storage and manipulation of FoodMenu details.
4
5
Programmatic creation of three tables and correct database connectivity
3
12
Good coding practices (Indentation, Comments, Naming Conventions, Readability)
3
13
Well presented report with student details, System architecture, test plan, and user instructions
6