-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExamRequirements.txt
76 lines (71 loc) · 6.74 KB
/
ExamRequirements.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Create the interface Vehicle with the method infoVehicle() which is returning String, must be inserted
Mark 3:
a. Create public class Car which must implement Vehicle interface, and It must be inserted 3 fields:
// weight - float, price - double, producer - String
// b. for this class fields it is mandatory to implement getters and setters, plus the default constructor (without parameters),
// there is NO constructor with parameters
// c. override implementation for the infoVehicle() method (from the Vehicle interface) to return the producer String
// d. the setters should throw Exception if the constraints are not fulfilled:
// - producer different from null and producer String length greater than 1
// - price and weight greater than 0 each
// e. Implements Serializable, Cloneable and Override the implementation for equals(), hashCode() and clone() methods
Mark 4:
// Create public class Utils which contains private static list field with interface as type: List<Vehicle>
// Insert the following methods:
// a. public static List<Vehicle> createCars(int n) throws Exception - for creating an ArrayList of n elements
// which are containing n default Car objects and it using the static field of the class (list)
// b. public static List<Vehicle> readCars(String file)
// - for reading and parsing text files with string lines for creating Car objects
// (e.g. please see for example carsList.txt file); first line is the weight in kg, second line is price in EUR and third line is the producer
// hint: use RandomAccessFile and read / parse line by line (first line is the weight in kg, second line is price in EUR and third line is the producer)
// c. public static void writeBinaryCars(String file, List<Vehicle> listP) - for writing binary the cars into the file
// hint: use ObjectOutputStream with FileOutputStream to serialize/save the Car objects from the ArrayList of the cars objects
// d. public static List<Vehicle> readBinaryCars(String file) - for reading binary the Car objects from the file and creating the ArrayList
Mark 5:
// a. create the public class VectThread which implements Runnable and contains 2 fields:
// - carList with interface as type List<Vehicle>
// - avgWeight is a real (double) number for storing the average weight of the cars list
// b. In the constructor read the file using readBinaryCars static method from Utils
// c. provide get methods for the both fields (carList and avgweight) of the class
// d. Within the override run method (with the signature in Runnable interface)
// - the developer should go through the carList and calculate the average of the weights from the car list objects (Car class - explicit cast)
Subject of + 2 points <=> Mark 6 or 7 (and parts of the mark 8):
// a. Create public class TCPServerSocketMultiT which handles multi-threading TCP server socket connections
// for implementing a proprietary communication protocol (set of rules)
// b. The class contains the following private fields:
// - serverSocket as ServerSocket, port = 50001 as int, f as File and vt as VectThread ("has a" relationship)
// c. The class contains the following methods and constructor:
// c.1 - constructor which get the port as parameter and create the serverSocket:
// public TCPServerSocketMultiT(int port) throws Exception
// c.2 - getter and setter for the field port
// c.3 - public void setFileName(String newFName) method which allocate memory for the field f, if and only if,
// the String parameter is different than null, otherwise is setting null
// c.4.- public void startTCPServer() throws IOException method which is having the infinite processing loop and is implementing 3 commands from the proprietary protocol
// HINTS for startTCPServer method:
// -create multi-threading by using lambda expressions from Runnable functional interface afters the blocking accept() method from serverSocket object
// -get the input stream as BufferedReader and output stream as ObjectOutputStream
// -initialize the vt field from class VectThread by passing the file absolute path from f field as parameters AND OBTAIN the list (ArrayList of Car objects) from the file
// -parse line by line the TCP request
// - if EXIT text command is received over the socket, then break the infinite loop of the processing and send TCP FIN packet back to the TCP client (e.g. by closing socket, etc.)
// - (mark 6) if GETFILE text command is received over the socket, then reply back the serialized list encapsulated in the vt object field
// - (mark 7) if GETJSON text command is received over the socket, then reply back with the list in JSON format
// - (mark 8) if GETDB text command is received over the socket, then reply back with the list as String produced by UtilsDAO.selectData() (please also take into account, you have to initialize JDBC connection and close it with static methods from UtilsDAO);
// YOU MAY NOT create the TCP client because it is already created into JUnit test framework; for mark 8, please also see UtilsDAO class (without UtilsDAO class, mark 8 can not be achieved)
Mark 8: create public class UtilsDAO with only one static field c from class Connection (SQL/JDBC)
// This class contains the following 3 static methods:
// a. public static void setConnection() - set the connection by using org.sqlite.JDBC driver and connection string: jdbc:sqlite:test.db
// b. public static void closeConnection() - close the SQL/JDBC connection
// c. public static String selectData() throws SQLException - for SQL selecting all the cars from the already created SQLite DB file
// - select * from CARS
// - CARS table is already created with the following columns id - INT, PRODUCER - TEXT, PRICE - REAL and WEIGHT - REAL
// - the String containing the view after selecting the entire table is having each table line separated with "\r\n" and each column value will be separated by ":"
// Subject+2 points <=> Mark 9/10:
// Create public class UDPServerSocket which implements a proprietary communication protocol and implements AutoCloseable (override specific method)
// It has 2 fields: socket - DatagramSocket and bindPort - int
// It contains the following constructor methods:
// a. public UDPServerSocket() throws SocketException - init bindPort on 60001
// b. public int getBindPort() - returns the bindPord field
// c. public void processRequest() throws IOException - receive UDP packets and process them (without infinite loop) with the following rules:
// - if the request contains W? , then the reply UDP packet contains as pay-load "UDPS".
// - if the request contains BYE , then the reply UDP packet contains as pay-load "BYE ACK" and close the resources (e.g. socket)
// - if the request contains any other pay-load , then the reply UDP packet contains as pay-load "ACK".