Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to implement a message buffer and response connector class using Java programming language. The following figure depicts a message buffer and response

image text in transcribedimage text in transcribedimage text in transcribed

You are asked to implement a "message buffer and response connector" class using Java programming language. The following figure depicts a message buffer and response connector class, followed by the detailed specifications of operations. The message buffer and response connector class has three operations, send0, receive), and replyO To test your implementation, your program should create two separate tasks (threads), a producer task and a consumer task. The producer task sends a message having a structure, (string, integer) e.g., ("add", 3) or (multiply", 7) - to a consumer task via a message buffer and response connector. The consumer task encapsulates a SimpleCalculation class that has two operations, add0 and "multiply()O. You should implement the SimpleCalculation class as well. When the consumer task receives a message from the connector, it extracts the message and then calls one of operations on the SimpleCalculation class depending on the message. For example, the consumer task calls the add0 operation if it receives a message like ("add", 3), while it calls the multiply) operation if it receives a message like ("multiply", 3). The add0 operation in the SimpleCalculation adds 10 to the integer in a message from the producer task and returns the result. The multiply0 operation multiplies the integer by 10 and returns the result. The producer task should print out the messages before it sends the messages to the consumer task. The messages are ("add", 1), ("multiply", 1), ("multiply", 2), ("add", 2), ("add", 3), ("add" 4), ("multiply", 3) sent to the consumer. Also the producer task should print out the results received from the consumer task You are asked to implement a "message buffer and response connector" class using Java programming language. The following figure depicts a message buffer and response connector class, followed by the detailed specifications of operations. The message buffer and response connector class has three operations, send0, receive), and replyO To test your implementation, your program should create two separate tasks (threads), a producer task and a consumer task. The producer task sends a message having a structure, (string, integer) e.g., ("add", 3) or (multiply", 7) - to a consumer task via a message buffer and response connector. The consumer task encapsulates a SimpleCalculation class that has two operations, add0 and "multiply()O. You should implement the SimpleCalculation class as well. When the consumer task receives a message from the connector, it extracts the message and then calls one of operations on the SimpleCalculation class depending on the message. For example, the consumer task calls the add0 operation if it receives a message like ("add", 3), while it calls the multiply) operation if it receives a message like ("multiply", 3). The add0 operation in the SimpleCalculation adds 10 to the integer in a message from the producer task and returns the result. The multiply0 operation multiplies the integer by 10 and returns the result. The producer task should print out the messages before it sends the messages to the consumer task. The messages are ("add", 1), ("multiply", 1), ("multiply", 2), ("add", 2), ("add", 3), ("add" 4), ("multiply", 3) sent to the consumer. Also the producer task should print out the results received from the consumer task

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago

Question

What is paper chromatography?

Answered: 1 week ago