Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. The UML diagram describing these first two classes is given as Fig. 1

image text in transcribed

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.

Message Characteristics:

Messages are unique and consist of a unique ID assigned at creation (starting at 10000 and incremented by 1 for each creation) and the actual text message. Similarly, the contentType for the message shall be the string text/plain.

>Constructors:

-Message() - create an empty message to be filled in. The message will have empty string addresses (not null ) and an empty a one line empty string message.

-Message(String content) - create message with content.

>Queries:

-long getUID() - returns the UID for the message

-String getSource() - returns the source address of the message

-String getDestination() - returns the destination address of the message

-String toString() - returns the message content

-String getType() - returns plain/text presently denoting a collection of text lines.

-String dump() - returns a multi-line representation of the message

UID: nnnnn Source: sourceaddr Destination: destaddr

ContentType: text/plain

Message:

>>Text of message

>Commands:

-void setContent(String text) - replace existing message content

-void setSource(String address) - set the source address of the message

-void setDestination(String address) - set the destination address of the message

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

Transmitter Characteristic:

A transmitter is an origination point for a message communication. In this program, a receiver may be directly connected to the transmitter. The transmitter can send a message to the connected receiver attaching its address as the source address of the message and the receivers address as the destination address.

>Constructors

-Transmitter() - create a transmitter with the source address unknown.

-Transmitter(String address) - create a transmitter with the specified address.

>Queries

-String getAddress() - return the address of the transmitter

>Commands

-void connect(Receiver receiver) - connect to the specified receiver so that messages can be sent to it. Only one connection at a time is possible for this program. Fail silently if there are issues.

-void send(Message message) - send message to connected receiver if any (fail silently), apply addresses for source and destination

-void disconnect() - disconnect from the connected receiver if any (fail silently)

Note:

Like all other modeling objects, Message , Receiver and Transmitter classes should not not contain I/O.

***Static Variable:

Static variables (variables outside any method and declared static) belong to the class not to an object of the class. That means they hold the same value for all objects (or other references) and be used for things such as counters to keep up with number of objects constructed, next serial number, etc.

private static int count = 10;

declares an integer variable which starts at 10 but any changes made to count will stick. The initialization is only done at the start of the program.

Also determining proper line separation.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago