Recent Question/Assignment

COIT132229 Applied Distributed Systems
Assignment 1 – Java Client/Server Application
Due date: Week 6 Friday (24th April 2020) 11:45 PM AEST ASSESSMENT
Weighting: 25% 1
Objectives
This assessment item is designed to test your understanding in Java TCP networking, Java Object Serialization/Deserialization, threading, file reading and writing using a client/server application development.
Assessment task
CQU aquatic centre offers swim facility to current students and their families. Entry to the swimming centre is accessible through any of the three automatic doors by keying in a registered student number followed by a 4-digit pin code preferably set to the year of birth. Each entry is charged a flat fee and the time should be persisted to a log file with two fields (student number space separated with entry date and time). Because of the flat fee structure, the entry details can be shared among family members. The system should accommodate both existing users with authentication and provide registration for new users. Administrator role is not relevant and will be discussed in the second assignment. The application should be implemented as a client/server model using java TCP sockets. The client program handles all the data entry and menu selections (1. Current Student 2. New Student 3. Exit). Current student should only be prompted for a student number and a pin code. New student registrations should be prompted to provide relevant details (Student number and a Pin Code). Appropriate error messages (Student exists, UnRegistered Student, Invalid Pin, Welcome or Student Created) should be received from the server after processing and displayed on the client. Student number is alphanumeric but cannot be empty. The client should create an instance of relevant type before sending to the server program for processing and storage. Every 3 minutes the contents from the data structures stored on the server need to be persisted to the text files. The server program should have the capability to concurrently handle multiple client connections (Thread-per-connection). Existing records are to be read and loaded from the provided text files (“studententry.txt” and logentry.txt”). When these text files do not exist, the system should handle this event and create new files.
Coding and Design
You can use the following class descriptions as a guideline for your design.
(At minimum two java files should be used)
Student: This class should implement serializable (Refer to figure 1).
LogEntry: This class should implement serializable and comparable interface to use an inbuilt java Collections.sort() method. (Refer to figure 1).
Example) SimpleDateFormat formatter = new SimpleDateFormat(-dd/MM/yyyy-HH:mm:ss-); WriteToFile: This class persist all the contents from the data structures to the text files.
TCPClient: This class handles the data entry with suitable menus and interacts with the user. This program creates an instance of (Student /LogEntry / String) on user selection before sending it to the server. Socket, ObjectInputStream and ObjectOutputStreamfor for TCP Connection should be used. The program should allow the client to enter the details for multiple entries.
TCPServer: This server loads existing records from the text files (“studententry.txt” and “logentries.txt”) to appropriate data structures preferably an ArrayList. A timer function should be used to regularly schedule the contents of the ArrayList to be written to the two text files every 3 minutes. The
“logentries.txt” should contain entries sorted by the student number. The server program should be running indefinitely ready to communicate with all future clients.
Figure 1(Design)
Your program should check user inputs for potential error and allow user to re-enter details where appropriate. The source code should be formatted properly following good programming practice
(appropriate variable names, indentation, comments, etc.…)
Sample Screenshots
The following screenshots show example outputs of the above program. You should only use these as references. Your program outputs can be similar but not necessarily the same.
Structure of studententry.txt and logentry.txt (two fields space separated) with Client/Server program interaction.
Studententry.txt
Logentry.txt
Client1
Client2
Output of TCPServer:
Report
Include an end user instruction and test manual. Run the program and take screenshot of program outputs for all tests with annotations. The test should demonstrate that your TCPServer can accept connections from more than one TCPClient. Provide screenshots of your “studententry.txt” and “logentry.txt”.
Assessment Submission
You should submit one Zip file containing the following files using the Moodle online submission system, by the due date:
• Student.java –Source code for the Student class
• LogEntry.java –Source code for the LogEntry class
• TCPClient.java –Source code for the TCPClient class.
• TCPServer.java –Source code for the TCPServer class
• Connection.java –Source code for the Connection class
(This class can also be provided inside TCPServer.java as an inner class)
• WriteToFile – Source code for the WriteToFile class
(This class can also be provided inside TCPServer.java as an inner class)
• Report.docx – A document file containing details as outline above.
Note:
1. If your program doesn’t compile or run, partial marks will be allocated by inspection of the source code.
2. Your understanding of the program will be examined using your report and the detailed java doc comments inserted in your source code files.
3. Please clarify any doubts you have by one of the means of discussing with your tutor, posting a query in the Q& A forum, or discussing with your colleagues or contacting the unit coordinator.
4. Please do not share your source code files or report with your colleagues which may lead to plagiarism.
Assessment Item 1 Marking criteria
S. No Total Marks - 30 Marks Allocated Marks Scored
1 1.The Client class enabling send/receive of Objects and Strings.
2.Appropriate data entry and handling of menu 3
2 1.The Server class accepts client request.
2.Multithreading (thread per client).
3.Loads text files to data structure correctly. 3
3 Client displays correct interaction messages.
1.Student Exists 2. Un-registered Student 3. Invalid Pin 4. Welcome
5.Student Created. 5
4 1.Timer scheduled correctly.
2.updates logentry.txt correctly.
3.updates studententry.txt correctly. 4
5 Student, LogEntry, Connection and WriteToFile classes with relevant methods and constructors. 4
6 Good coding practices (Indentation,
Comments, Naming Conventions, Readability) 2
7 Well-presented report, detailed user manual showing compilation steps and order of running the programs. 2
8 Screen shots of running programs to cover all tests. 2
Sub-total 25
Penalties
Late penalty -1.25 (5% per
Calendar day)
Plagiarism As per policy
Total 25