Download Assignment 2 - Your Projects

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Concurrent and Distributed Systems (2015-16)
Assignment 2 (50% of Total CW Marks)
Submission Deadline: Wednesday Week 10 (20 April 2016 at 11am)
Submission Instructions: This coursework has two elements related to it, both
elements require Development, Testing and Evaluation Reports as detailed in
each question. The code should be submitted on a CD/pen-drive in the form of
NetBeans Java Project. Put all the projects inside a folder Named using using the
following convention: SurnameName_CDS_CW2.
Finally, the working implementation should be demonstrated during the
laboratory session on week 10. The Report should be submitted to the SCM
School Office on or before the submission deadline.
Question 1 - [70 Marks]
You are required to develop a Client/Server system in Java where a client can connect
to a server (possibly running on a different machine). The server allows the client to
submit a six digit number and then the server will respond with the student’s name and a
set of three module marks. A connected client can keep requesting student details until
they terminate the communication by entering the value -1. If they enter an invalid
student number they should be informed accordingly and allowed to continue with the
communication.
(a) Using the utility classes below which store details of existing students, develop and
test this client/server (iterative) system.
(40 marks)
Assessment Criteria:
Server development 10%
Client development 10%
Testing and evaluation 10%
Demo 10%
import java.util.List;
import java.util.ArrayList;
import studentdetailstype.StudentDetailsType;
public class StudentData {
final int LIST_LENGTH = 6;
private final List<StudentDetailsType> StudentDetailsList;
public StudentData() { //constructor
StudentDetailsList = new ArrayList<>();
StudentDetailsList.add(new StudentDetailsType(123456, "Joe_Lynch", 35.75f, 45.75f, 57.50f));
StudentDetailsList.add(new StudentDetailsType(234567, "Mary_Lynch", 65.75f, 55.70f, 77.50f));
StudentDetailsList.add(new StudentDetailsType(345678, "James_Green", 45.55f, 85.15f, 97.50f));
StudentDetailsList.add(new StudentDetailsType(456789, "Peter_Jones", 25.75f, 45.75f, 17.50f));
StudentDetailsList.add(new StudentDetailsType(567890, "June_Brown", 85.75f, 55.25f, 47.00f));
StudentDetailsList.add(new StudentDetailsType(678901, "George_Campbell", 85.75f, 95.75f, 77.50f));
}
public boolean validStudentNumberFlag(int studentNum) {
for (StudentDetailsType element : StudentDetailsList) {
if (studentNum == element.getStudentNumber()) {
return (true);
}
}
return (false);
} //end validStudentNumberFlag
public StudentDetailsType getStudentDetails(int studentNum) {
for (StudentDetailsType element : StudentDetailsList) {
if (studentNum == element.getStudentNumber()) {
return (element);
}
}
return null;
} //end getStudentDetails
} // end StudentData
import java.io.Serializable;
public class StudentDetailsType implements Serializable {
int studentNumber;
String studentName;
float result1, result2, result3;
// constructor
public StudentDetailsType(int theStudentNumber, String theName, float mark1, float mark2, float mark3) {
studentNumber = theStudentNumber;
studentName = theName;
result1 = mark1;
result2 = mark2;
result3 = mark3;
}
public StudentDetailsType() {
this(0,"",0.0f,0.0f,0.0f);
}
public int getStudentNumber() {
return (studentNumber);
}
public String getStudentName() {
return (studentName);
}
public float getResult1() {
return (result1);
}
public float getResult2() {
return (result2);
}
public float getResult3() {
return (result3);
}
} // end StudentDetailsType
(b) Develop a multi-threaded version of the above client/server system, so that
multiple clients can connect at the same time.
(30 marks)
Assessment Criteria:
Server development 10%
Testing and evaluation 10%
Demo 10%
Question 2 [30 Marks]
In Question 1 the student data is hard coded in the StudentData class. Replace
StudentData with a class called StudentDataDB which communicates with the JavaDB
database. The student data is now stored in a table in the database.
Integrate this change into a database version of the multi-threaded server.
Note. JavaDB is integrated into Netbeans - see the document “Java and Databases
(JavaDB) ” on the module web page for details on how to use JavaDB.
The StudentDetailsType class should remain the same. The client will also remain the
same.
Assessment Criteria:
Server development 10%
Testing and evaluation 10%
Demo 10%
Hint(s): The Server and Client classes should for convenience be stored in
different projects in Netbeans.
If you are using Object Streams for reading or writing objects then you will need
StudentDetailsType to also be in a separate project.
All testing can be done from Netbeans.
For the client and each server you should add a copy of the StudentDetalisType
JAR file to the corresponding Libraries folder and then you can import it into your
program so that you can use it as required.
When a class is successfully compiled in Netbeans, a JAR file for that class is
stored in the “dist” folder if you need to use it.
Note. Each Java program should be comprehensively tested, with generated
output to illustrate the activity of the system. Also comment as part of the
evaluation on any problems or difficulties you encountered when attempting this
assignment, or any assumptions you made regarding the problems/solutions.