OOP Lab Task 4

De la WikiLabs
Versiunea din 14 decembrie 2013 23:06, autor: Rhobincu (discuție | contribuții) (Pagină nouă: == Required Tutorials == * The Object Oriented Paradigm; Classes and Objects * Notions About the Java Language * Writing and Executing a Java Program * [[Java Syntax; A P...)
(dif) ← Versiunea anterioară | Versiunea curentă (dif) | Versiunea următoare → (dif)
Jump to navigationJump to search

Required Tutorials

Requirements

  • Change the classes Message and SystemMessage so they can be serialized. Use serialVersionUID = 1 for Message and serialVersionUID = 2 for SystemMessage;
  • Write a class Client which should only contain the main method. This should take three arguments, at runtime, representing a host, a port and a username. Create a network socket to connect to the specified server. Using class java.io.Console, read messages from the keyboard, instantiate objects of type Message with sender being the username, receiver being null and content being the message read from the keyboard, and serialize the objects to the server. The client should only stop if forced by using Ctrl + c key combination;
  • Write a class Server that should only contain the main method. It should receive a single argument at runtime, representing the port on which to listen for incoming connection. Once a client is connected, the server should continue to read objects of type Message from the input stream, and display them in the console by using methodtoString();
  • Test the two classes by running them both in different consoles.