cs586 hw2 solution
TRANSCRIPT
-
8/3/2019 CS586 HW2 Solution
1/8
HOMEWORK ASSIGNMENT #2CS 586; Spring 2010
Due Date: March 24, 2010Late homework 50% offAfter March 28 the homework assignment will not be accepted.
The hardcopy of the assignment must be submitted. Electronic submissions are notacceptable. Notice that the Blackboard homework assignment submissions are only
considered as a proof of submission on time (before the deadline).
PROBLEM #1 (35 points):There exist two servers in the system that provide the following services fro clients:
Server #1:
int multiply(int, int) // two numbers are multipliedint add(int, int, int) // three numbers are added
float add(float, int) // two numbers are added
char next_letter (char) // returns the next letter in the alphabet
char previous_letter(char) // returns the previous letter in the alphabet
Server #2:
float add(float, int) // two numbers are added
int subtract(int, int) // two numbers are subtractedfloat multiply(float, int) // two numbers are multiplied
int multiply(int, int) // two numbers are multiplied
char next_letter (char) // returns the next letter in the alphabet
In addition, there are two clients: Client_A and Client_B
Client_A may request the following services:
float multiply(float, int) // two numbers are multiplied
float add(float, int) // two numbers are addedint add(int, int, int) // three numbers are added
char next_letter (char) // returns the next letter in the alphabet
Client_B may request the following services:
float add(float, int) // two numbers are addedint add(int, int, int) // three numbers are added
int subtract(int, int) // two numbers are subtracted
char next_letter (char) // returns the next letter in the alphabet
Both clients do not know the location (pointer) to servers that may provide these services.
Devise a software architecture using a Client-Broker-Server architecture for this problem.In this design the clients are not aware of the location of servers providing these services.
Provide a class diagram for the proposed architecture. Describe in detail eachcomponent (class) of your design and operations supported by each class using
pseudo-code. In your design all components should be decoupled as much aspossible.
Provide a sequence diagram to show how Client_A gets add(float, int) service.
-
8/3/2019 CS586 HW2 Solution
2/8
-
8/3/2019 CS586 HW2 Solution
3/8
-
8/3/2019 CS586 HW2 Solution
4/8
PROBLEM #2 (30 points):Consider an application for an intelligent house. The application receives events from
sensors distributed throughout the house. Based on these events the application issues
commands on a humidifier, blinds, and an air conditioner (AC), i.e., turn on humidifier,
turn off humidifier, open blind, close blind, turn on AC, turn off AC. Although several
manufactures (e.g., manufacturer CBA, manufacturer EAB) provide the hardware to buildsuch applications, interoperability in this domain is poor, preventing the mix and match of
devices from different manufactures, and thus making it difficult to develop a single
software solution for all manufactures. The current design is shown below. In this design,
the application (AppControl class) is responsible for identifying objects controlling
humidifiers, blinds, and an air conditioner of the same manufacturer.
CBA-humidif ier
TurnOn( )TurnOff( )
EAB-humidif ier
TurnOn( )TurnOff( )
CBA-Blind
Open( )Close( )
EAB-Blind
Open( )Close( )
CBA-AC
ON( )OFF( )
EAB-AC
ON( )OFF( )
1
Humidifier
TurnOn( )TurnOff( )
*
Blind
Open( )Close( )
1 AC
ON( )OFF( )
AppControl
1
humidifiers
*
blinds
1
air conditioner
In a better design the AppControl class should be shielded from the issues of identifying
objects related to the same manufacturer. Use the abstract factory design pattern to solve
this problem. In your solution the AppControl class should be completely de-coupled
from the manufacturer of the underlying products. In your solution provide:
The class diagram and briefly describe the responsibility of each class and thefunctionality of each operation. You do not have to provide any description for
classes/operations of the above class diagram (only new classes/operations should
be specified using pseudo-code).
A sequence diagram showing how AppControl class will get Humidifier object,two Blind objects, and AC object of the EAB manufacturer and then issue the
following operations on these objects: TurnOn(), Open(), Open(), and ON().
-
8/3/2019 CS586 HW2 Solution
5/8
-
8/3/2019 CS586 HW2 Solution
6/8
-
8/3/2019 CS586 HW2 Solution
7/8
PROBLEM #3 (35 points):There exist two inventory software systems S1 and S2 that maintain information about
books in several warehouses, i.e., a functional core of each inventory system is to keep
track of the number of books in warehouses. Books may be added or removed from thewarehouse and this should be reflected in the inventory system. Both inventory systems
support the following operations:Operations supported by the inventory system S1:AddBook (isbn, warehouse id) //add a book to a warehouse id
DeleteBook (isbn, warehouse id) //delete a book from a warehouse id
GetNumBooks (isbn) //get the total number of a specified book in all warehouses
IsBook (isbn) //does a specified book exist in the system?
Operations supported by the inventory system S2:InsertBook(isbn, warehouse id) //add a book to a warehouse id
RemoveBook(isbn, warehouse id) //delete a book from a warehouse id
GetNumOfBooks(isbn) //get the total number of a specified book in all warehouses
IsBook(isbn) //does a specified book exist in the system?
The goal is to combine both inventory systems and provide a uniform interface to
perform operations on both existing inventory systems using the strict Layeredarchitecture. The following top layer interface should be provided:
AddBook(isbn, warehouse id) //add a book to a warehouse id
RemoveBook(isbn, warehouse id) //delete a book from a warehouse id
GetNumberOfBooks(isbn) //get the total number of a specified book in all warehouses
RegisterPriorityBook(isbn, minimum level)
UnRegisterPriorityBook(isbn)
ShowPriorityBooks()
Notice that the top layer provides three additional functions (RegisterPriorityBook(),
UnRegisterPriorityBook(), and ShowPriorityBook()) that are not provided by the existinginventory systems. These functions allow watching the status of priority books. The
user/application can register a priority book by providing its minimum level, i.e., aminimal number of books of a specified book that should be present in all warehouses.When the number of books of a priority book (a registered book) reaches the level below
the minimum level, the system should store, e.g., in a buffer, the current status (number
of books) of the priority book. The current status of all priority books whose level isbelow the minimum level can be displayed by issuing ShowPriorityBooks() function. The
function UnRegisterPriorityBook() allows removing a specified book from a list of
priority books.
Major assumptions for the design:
1. Users/applications that use the top layer interface should have an impression thatthere exists only one inventory system.
2. The bottom layer is represented by both inventory systems.3. Both inventory systems should not be modified.4. Your design should contain at least four layers. For each layer identify operations
provided by the layer.5. Each layer should be encapsulated in a class and represented by an object.6. Provide a class diagram for the combined system. For each class list all operations
supported by the class and major data structures. Briefly describe each operationin each class.
-
8/3/2019 CS586 HW2 Solution
8/8