Sie sind auf Seite 1von 3

Laboratory :

Credit : 50 points

Due date : Before November 17, 2016


Objectives :

To learn design using design patterns.


There are many design patterns, as you have learnt in the theory lecture sessions. This
assignment will be using only two patterns State pattern and Publisher-Subscriber
pattern.
Preferably implement it in Java, because user interface can be easily and comfortably
designed in Java than in C++. Refer to the brief introduction I have given in GUI
design in Java in my lecture.
To perform unit testing and other coverage testing method such as statement
coverage, branch coverage on the code you have developed.
To learn how to conduct mutation testing.

Problem Statement:
Suppose that you are hired by a nuclear power plan to design the control system of its reactor.
The most important attribute of a nuclear reactor is the temperature of its core. Reactor is
provided computerized controls for decrementing and incrementing the temperature. These
controls are manipulated from a remote console, which is manned by our most competent
employee. Sensors are scattered throughout the power plant. These include thermometers,
and various types of alarms and thermostats that go off when the reactor's temperature rises
above the critical level, say 1500 degrees. You have to design the control system. Your
design must be such that the state of the reactor at any time due to incrementing and
decrementing operations of its temperature must be captured properly and any sensors which
need to be activated at a particular state of the reactor must be also incorporated. You need
to have the ability to add more and new types of sensors and consoles to the system without
modifying the reactor control code.
Design of the solution:
The design of our reactor is given in the class diagram in the last page. As you have seen that
our Reactor has only two states Normal or Critical. Normal state is the state in which the
temperature of the Reactor is below the critical temperature limit. When the Reactor is in this
state it temperature can be either increased or decreased. Other state is the Critical state. In
this state, no further increment operation will be allowed to be performed, but decrement
operation can be performed. This state management can be done by the State Pattern marked
with red box.
Many sensors are attached to our reactor. They will be informed whenever any increase or
decrease in the temperature of the reactor has occurred due to increment and decrement
operation performed by the operator from its console. So, all our sensors are Subscribers.
They are registered to our Publisher i.e. Reactor. These sensors reacts based on the state of

the Reactor. For example, our Alarm and Printer will react only when the Reactor is in the
Critical state. In this state, Alarm will be sounded and Printer will start printing the
temperature value. ( While implementing, it displays in the console ).Thermometer will be
showing the current temperature in all states. This is implemented using Publisher-Subscriber
pattern marked in green box in the diagram on the last page.
Interface Requirement:
The console of the operator will look like the following Java GUI screen. Note that our
thermometer is implemented as a JLabel object in the middle. Two operations can be initiated
by the two JButtons provided. Printer is the computer console. Finally Alarm is the speaker
of your computer. ( You must search how to beep our computer speaker in Java).

Your Tasks:
I have highlighted only the brief outline of the design. Now you have to complete the
following task:

The UML class diagram given must be completed with full information of data
members and member methods of each class.
Two interaction diagrams must be provided showing the message passing among the
various objects of the class diagram, when the INC or DEC button is pressed by the
user in its control console.
Finally, Java code must be submitted and demonstrated in the lab.

How to carry out:

The same group you formed for assignment 4 will be retained.

Final Line :

All the best! Any help I am always available.

Preliminary Design Class Diagram:

Subscriber

Publisher

Reactor

Alarm

State

Normal

Critical

Thermometer

Printer

Das könnte Ihnen auch gefallen