Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: zz-x2580
Laboratory work #5 | Network application
Objectives
This laboratory work intended for you to master basic principles of network interaction and serialization in the
object-oriented solution.
Instructions
Having your solution of the Laboratory work #4, split your program into two programs. The first program
implementing the server-side responsible for data carrying collection and operations to perform. The second
program implementing the client side responsible for user interface – retrieving command from the user to ask the
server for operations and get specific data items to display.
1. Review the lecture about the network programming and serialization.
2. Remember the last lab task from the first semester (Laboratory work #6 about Collections): there you had to
create two classes for your applied domain scope – a data item class and a class carrying the collection of
data items and responsible internal operations with data in it.
3. Split your program into two (or create two separate projects as was demonstrated in the lecture #7)
a. The server program listens for incoming connections and receives commands to perform with the
collection of data items. Like what the Lab #6 was doing in the first semester but with networking
instead of console. Use classes created during step 2 of Lab #4 for this step.
b. The client program connects to the server program and shows the graphical UI. Like in the previous
Lab #4 in this semester), retrieves the data items to display from the server side, when the user
presses the command buttons, the program prepares all the required data and sends the command
to the server for it to modify the collection and answer with the result data to display. Use classes
create during steps 3 of Lab #4 for this step.
c. Modify pieces created for step 4 of Lab #4 for send commands to the server side, retrieve the result
and update the UI state.
4. Use network protocol according to you variant number to implement the solution
Extra tasks for additional points:
Modify your server program so that it would be able to preserve data being operated between
program launches by saving them on the server stopping and loading them when the server starts.
No data should be preserved on the client side.
Modify your data storage approach to use granular operations based on the last lecture about
Advanced data organization.
Variants
See variants table for data transfer approach and use your variant’s GUI layout and applied domain scope from the
variant of Lab #4.
Data transferring approach to use
Number UI control
1 TCP protocol
2 UDP protocol
3 Java RMI
Extra information
Brief overview of some IO classes to know about:
● Writer classes
FileWriter
OutputStreamWriter
BufferedWriter
StringWriter
● OutputStream classes
DataOutputStream
BufferedOutputStream
ByteArrayOutputStream
FileOutputStream
PrintStream
● Reader classes
FileReader
InputStreamReader
BufferedReader
StringReader
● InputStream classes
DataInputStream
BufferedInputStream
ByteArrayInputStream
FileInputStream
● Parsing and formatting
Scanner
Formatter
ByteBuffer
● File system management
java.io.File
java.nio.file.Path
java.nio.file.Files