Professional Documents
Culture Documents
OO120 - Object-Oriented Analysis & Design Lab Solution - 1095
OO120 - Object-Oriented Analysis & Design Lab Solution - 1095
OO120 - Object-Oriented Analysis & Design Lab Solution - 1095
1-1
Copyright 1997 Sun Microsystems, Inc. All Rights Reserved. SunService October 1995
1
League
director Judge
Skating league
application
Meet
director
2. Possible use cases based on the context diagram are shown below.
● League director
- Delete team
- Schedule a meet
● Meet director
● Judge
- Enter score
- Meet
- Competition
- Event
- Judge
- Skater
- Team
Notes
● Score is not a key abstraction. To find out why, try to define it. You
will eventually come to the conclusion that score is an attribute of
a performance. This is one of the three way that you can find the
Performance class.
1. The static model for the skating league problem is shown below.
Team Meet
Competition
Skater Judge
Event
Entrant
Team Meet
Host
Member
Competition
Skater Judge
Contest
Assigned
Performer Qualified
Event
The fact that you cannot name this association without ambiguity
is an indicator that you have missed a class in the initial analysis.
In this case, a Judge is not qualified for a single event, but rather
for all events of a given type. You will have to add EventType to
the static model.
Entrant
Team Meet
Host EventType
Member
Competition Qualified
Characterizes
Skater Judge
Contest
Assigned
Performer
Event
Entrant
Team Meet
Host EventType
Member
Competition Qualified
Characterizes
Skater Judge
Contest
Assigned
Performer
Event
4. The attributes for each class in the static model are shown below.
Meet
Team
Name
Name Entrant Date
maxSize Location
Host
EventType
Member
Competition Type
Gender Qualified
ageRange
Skater Characterizes
Name Contest
Address Judge
phoneNumber Name
datOfBirth
Performer Address
Gender phoneNumber
Event Assigned
startTime
Participant
Meet
Name
Address
phoneNumber
Competition
Skater Judge
datOfBirth
Gender Event
beginDate dateObtained
Score expiration Value
endDate
Judge
Team
Registration Assignment
dateReceived
Status
Event
Meet
Fail
Unlocking
Pass
/Alarm
Coin
Coin /thankYou
/Unlock Unlocked
Locked
Pass
/Lock
Locking
Fail
Broken
Skater GUI
Skater
league
Persistent
date
Skater GUI
Skater
league
Persistent
date
Note – The Skater league depends on the other two subsystems. You
could also have built it so that there were peer-to-peer associations
between the subsystems, rather than the client-server model shown.
A:
Coin
Coin
Unlock
Pass
Pass
Lock
B:
Coin
Coin
Unlock
Fail
On
Return coin
C:
Pass
Pass
Turn on
The design for the getCost() operation for a part is shown below.
Part
Costing policy
getCost()
Rollup Rollup
factor factor
1. The design of the attributes of the Skater class are shown below.
class Skater {
private:
Name myName;
Address myAddress;
Date myBirthDay;
PhoneNumber myPhoneNumber;
enum myGender;
}
You could have used a char* for both the name and address
attributes. Here, classes were used for these attributes in case there
were come complex manipulations involved. For example, if the
names were to be alphabetized.
2. The design of the associations of the Skater class are shown below.
class Skater {
private:
set <Membership>* my Memberships;
set <Performances>* my Performances;
}
This assumes that you have a set object in the library that can be
parameterized with whatever type you want. A set was chosen
because a set automatically eliminates duplications. If you had
wanted to allow duplications, you could have selected some other
structure.
Lab: Reification
CoinEvent Turnstile
class CoinEvent {
public:
CoinEvent(Turnstile* theTurnStile) {
myTurnstile = theTurnStile;
myTurnstile.coinEvent();
}
private:
Turnstile* myTurnstile;
}
The expanded static model for the garage door opener is shown below.
Garage door
opener Garage door state
depress()
fullOpen() depress(motor* theMotor)
closed()
Opening Closing
class GarageDoorOpener {
public:
void depress();
void fullOpen();
void closed();
private:
OpenState* open;
ClosedState* closed;
OpeningState* opening;
ClosingState* closing:
StoppedState* stopped;
GarageDoorState* myState;
motor* myMotor;
}
GarageDoorOpener::depress() {
myState.depress();
if (myState == open) myState = closing;
else if (myState == opening) myState = stopped;
else if (myState == closed) myState = opening;
else if (myState == closing) myState = stopped;
else myState = opening;
}
GarageDoorOpener::fullOpen() {
myMotor.off();
myState = open;
}
GarageDoorOpener::closed() {
myMotor.off();
myState = closed;
}
class GarageDoorState{
public:
virtual void depress(motor* theMotor) = 0;
}