Question: JAVA PROGRAM: ( Model Message/Transfer System) Build a object oriented model of parts of a message transfer system that can transfer digital data between two
JAVA PROGRAM: (Model Message/Transfer System)
Build a object oriented model of parts of a message transfer system that can transfer digital data between two end points (perhaps with intermediate relays). Start with three objects: message, transmitter, receiver. The UML diagram describing these first two classes is given as Fig. 1

Fig, 1
Messages consist of meta-data (things about a message) and then the message content, (text, system information, image, binary glob) etc. although in this program, it will be strictly text support.
Receiver Characteristics:
A receiver is an endpoint of a transmission. For this program, a receiver may be connected to a transmitter. The transmitter delivers a message to the receiver. The receiver can note that a message is available and it can be retrieved by getting the message. In this program, if a second message comes in before the first is retrieved then an overrun condition exists. The overrun condition can be cleared with with a reset which will also clear any available message.
>Constructors
-Receiver() - create a receiver with an address of unknown
-Receiver(String address) - create a receiver with specified address
>Queries
-String getAddress() - returns address of receiver
-boolean overrun() - returns true if one or more messages are delivered while the receiver is holding a message
-boolean available() - returns true if message available
>Commands
-void deliver( Message message) - deliver message into Receiver
-Message getMessage() - returns message from receiver if available or null otherwise
-void reset() - resets the overrun condition on the receiver and clears any stored message inside the receiver
So far this is the code for Message class:
public class Message { static long messageID = 0; String message; String contentType = "text/plain"; String source; String destination; // Constructors Message(){ message = ""; } Message(String msg){ message = msg; } // Accessors public long getUID() { return messageID; } public String getSource() { return source; } public String getDestination() { return destination; } public String getType() { return contentType; } public String toString(){ return "Message " + messageID+ ": "+message; } public String dump(){ return "Message " + messageID+ ": "+message + " From: "+ source + " to: "+destination; } // Mutators public void setContent(String text){ message = text; } void setSource(String address) { source=address; } void setDestination(String address) { destination=address; } }
Transmiter Transmitter Transmitter(String addr) getAddr0 send(Message message) Message conect(Receiver receiver) +Message0 +Message(String line) GeUID + geeSource0 geDestination + toString0 + dump) + setcontentSaring ine) Receiver setSource(String address) Receiver0 Receiver(Saring addr egetAddr e overnun - avalable0 delivertMessage message) getMessage reset
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
