Assignment title: Information


​​ 1 Assessment details for ALL students Assessment item 2— Assignment 2 Due date: Friday of Week 10 ASSESSMENT Weighting: 20% Length: NA 2 Objectives This assessment item is designed to test your understanding in Java TCP networking, multi-threaded programming, and client/server application. Assessment task Write a java application using Java TCP API Socket to implement a simple client/server application using multi-threaded programming RMI. Your task for this assignment is to design and implement RMI using Java TCP API Socket and object serialization and multi-threaded programming allowing multiple clients to use the server service simultaneously. You should use object serialisation for client-server communication by writing to ObjectOutputStream and reading from ObjectInputStream. You can use String data type to read input from the user and format your message. You have to demonstrate the use of your application to provide clients with server side services by using the given MathsTutor class which you can obtain by downloading the MathsTutor.java file from the course website. The MathsTutor class implements a primary school level maths tutor which will provide maths exercises, and evaluate answers. The MathsTutor allows the user to practice arithmetic operations as chosen by the user. The user can select one of addition, subtraction, multiplication, or division. The MathsTutor has got method to create arithmetic problems using randomly generated double digit numbers. You should modify the given MathsTutor class for creating serializable object. When client connects to the server, the server sends a MathsTutor object to the client. The client side should get the user name who practices the maths exercise. The client has to invoke the method to display the available operations, read user choice. The client should invoke other MathsTutor methods to create 10 problems, execute the required operation, and check the result. The user should be able to stop the service by entering a single character 'Q' or 'q'. When the user quits after practicing number of operations such as 10 problems each in addition and subtraction, the client should send a summary to the server containing user name, attempt, and operation practised in each attempt and score. 2 The server should allow multiple clients to use the service at the same time following thread-per-connection model. When a client disconnects after completing the maths practice The server should display the client address, and the summary received from the client. Some of the methods required for the client side to provide the service of a maths tutor are included in the MathsTutor class. You can use these methods and include additional methods as required. To implement the framework, you need to implement at least three Java classes in addition to modifying the given Maths class: 1. A Java application to implement the client; 2. A Java application to implement the server; and 3. A Java class to implement the request processing thread. The communication between the server and the client must use TCP protocol; use of any other protocols will incur no marks to be awarded for this part. You will be running the client and server using two Java Virtual Machines (JVMs) from the same computer or physical machine. As a result, the name of the server machine can be 'localhost'. You use the Java APIs ServerSocket, Socket, and a derived Connection class from Thread. The server continuously listens on the socket for client messages. As demonstrated below, start the server and client in two JVMs. Figure 1. and 2 show 2 users simultaneously using the Maths service from two clients Figure 1 Enter your name Kate Welcome to Maths Tutor Service. The available maths exercises are: Addition: Enter 'A' or 'a' Subtraction: Enter 'S' or 's' Multiplication: Enter 'M' or 'm' Division: Enter 'D' or 'd' Enter 'Q' or 'q' to quit s 98 73: 25 Correct 50 42: 8 Correct 54 28: 26 ……….. ………. Attempt Operation Score 1 Subtraction 4 2 Addition 5 3 Figure 2 An example showing server side message is shown in Figure 3. Figure 3 Source code Files Follow good programming practices in writing the source code using correct indentation, meaningful variable names, inclusion of comments, informative error message, and userfriendly interface. Enter your name Lily Welcome to Maths Tutor Service. The available maths exercises are: Addition: Enter 'A' or 'a' Subtraction: Enter 'S' or 's' Multiplication: Enter 'M' or 'm' Division: Enter 'D' or 'd' Enter 'Q' or 'q' to quit a 9 0 63: 153 Correct 40 42: 82 Correct 54 26: 80 ……….. ………. Attempt Operation Score 2 Addition 9 The Received Message from Client at address:/127.0.0.1:54173 ======================================== Kate Attempt Operation Score 1 Subtraction 4 2 Addition 5 The Received Message from Client at address:/127.0.0.1:54181 ======================================== Lily Attempt Operation Score 1 Addition 9 4 Documentation After the implementation of the framework, prepare a document to include: 1. Additional constructs required for the server side to save the results and make it available to the clients for future logins. Write about using a database synchronising multiple thread writing to the database. 2. Test results (screenshots/test cases with results to show that your application is correctly working)). 3. An end user instruction about how to use your software. Your document should be formatted correctly with your name, studentId, course name, course code on the front page, and correct spelling, and grammar. Submission You need to submit one zip file containing the following files via the online submission system from the course web site ((Note: the file names/class names could be changed to meaningful names). 1. Java source code file of the server: MathsTutorServer.java 2. Java source code file for the client: MathsTutorClient.java 3. These source code file for modified MathsTutor class which is serializable. These source code files must be able to be compiled by the standard JDK (Java Development Kit) from Oracle (http://www.oracle.com/technetwork/java/index.html). 4. A Microsoft Word document to address the issues as specified in documentation above. Any hardcopy or email submission will not be accepted. References 1. Java TCP API Socket and ServerSocket (Week-2 contents, http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html, and http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html); 2. Java Object Serialization (Week-2 and Week-3 contents and http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html); 3. Java multi-threading (Week-4 contents, http://docs.oracle.com/javase/7/docs/api/java/lang/Runnable.html, and http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html). 4. https://docs.oracle.com/javase/tutorial/essential/concurrency/ (Continued on next page) 5 Assessment Item 2 Marking criteria S. No Total Marks - 20 Marks Allocated Marks Scored Programming 1 Java TCP Networking, Multi-threading and runnable class enabling continuous send/receive messages between server and client 3 2 Serialized MathsTutor class so that MathsTutor object can be sent from the server to the client. 2 3 Correctly running Server class which sends the serialized object and receives messages from the client 2 4 Correctly functioning Client class which receives the MathsTutor object, invokes methods and sends summary to the server 3 5 Good coding practices(Indentation, Comments, Naming Conventions, Readability, user friendly interface) 1 Documentation 6 Documentation on thread synchronisation and safe writing to the database. 5 7 Testing: Test results (screenshots/test cases with results) 2 8 End user instruction 1 9 Report formatting, grammar, spelling 1 Penalties 10 Late penalty 5% per working day (- 1 mark) 11 Plagiarism As per policy 12 Total 20