Midterm Study Guide

EECS 486 – Winter 2003

 

Question 1

 

Statechart Diagram

 

Draw a statechart diagram for a home phone.  The functionality of the phone is described in detail below.  Make and state reasonable assumptions about the behavior of the phone that are not explicitly described below.

 

The phone is composed of keys 1-9, the redial button, a caller id function, a show-caller id button, a voice message function, a show voice message button, screen, the power plug, the phone line, and the handle (life the handle to start calling someone).

 

Assume that the phone is initially powered and connected to the phone line and is working properly.  Pressing the redial button calls the previously called number.  Pressing the caller id button plays the most recent voice message first, then the others.  Initially the phone has a welcome message to the user.

 

Question 2

 

For the doll presented in class:

 

1. Draw and describe its use case diagram.

2. Draw the statechart diagram.

 

Question 3

 

Draw the class diagram for a day planner with the following behaviors:

 

The planner should allow you to add activities to an agenda for each day of the year.  Determine what attributes you need to keep track of events (start time, duration, title, etc.).  You should be able to add and remove events. Also, the planner should alert the user when two events have a time conflict. This happens when the second event is entered.  You have the option of repeating events on a daily, monthly, or weekly schedule. The planner program can be set to display the current month, current week or the current day.

 

You should determine what operations are necessary to enter or remove an event, update an event and change the display.  Draw a use case diagram for the day planner program.  Now, write a short scenario that proves to you the use case diagram is complete and correct.

 

Question 4

 

An orchestra is a group of musicians. They are divided into four groups:  strings, woodwinds, brass, and percussion.

 

The string section consists of approx. 10 first violins, 15 second violins, 10 violas, 10 cellos, and 8 basses. The woodwind section consists of flutes, oboes, clarinets, and bassoons.  The brass section consists of French horns, trumpets, trombones, and a tuba. The percussion section usually consists of five players, one of whom plays the timpani (kettledrums). The other players play drums or other percussion instruments as needed.

 

An orchestra is led by a conductor. His job is to interpret the music and cue the appropriate players according to the score. Each player must follow the conductor's cues and tempo.

 

Draw the class diagram for an orchestra.

 

Question 5

 

The door on a CAEN lab in the EECS building is, by default, locked and controlled by a MCard-reading machine.  If a student's MCard is authorized, the door will unlock for 10 seconds when the card is swiped through the reader.  The door will relock after 10 seconds if it was not opened, or after it is closed if it was opened.  The reader's display always shows the current time/date and, when a card is swiped, gives a success or error message.

        The card reader also has a keypad that can be used to manually override the door if a certain password is entered.  While in manual override mode, one can set the time/date on the reader's display and which key server the reader consults for access.  If the door is not in manual override mode and is held open for 60 consecutive seconds, a very annoying alarm sounds until the door is closed.

 

        1. Sketch a class diagram for the system.

        2. Draw a statechart diagram for the system.

 

Question 6

 

Create a statechart diagram for the interactions of four traffic lights at an intersection.

The lights should work as in reality that won't cause any confusion and traffic accidents.

 

Question 7

 

Create a use case diagram of a basic cell phone with the following features.

 

The cell phone can be used to:

 

-call someone

-store 50 phone numbers

-store 5 quick dial numbers (where you just hit the appropriate button and then the call button)

-set the time (hours, minutes)

-check your voice mail (using a special button).

 

State all reasonable assumptions when answering

 

Question 8

 

Draw and describe the class diagram for the board game monopoly.

 

 

 

 

 

Question 9

 

Draw the use case and class diagrams for a basic instant messaging client with the following properties and functionality.

 

Allows user to login by inputting username/password.

Allows user to logoff.

User can toggle their profile availability.

User can make their profile visible, and edit it.

User can select users on their buddy list and view their profiles.

User can add users to their buddy list.

User can add users to their ignore list.

User can send messages to other online users on their buddy list.

User can send files to other online users on their buddy list.

Displays a list of online buddies when logged in.

Displays a list of offline buddies when logged in.

 

Question 10

 

A product is to be installed to control elevators in a building with m floors. The problem concerns the logic required to move elevators between floors according to the following constraints:

 

- Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and cause the elevator to visit the corresponding floor. The illumination is canceled when the elevator visits the corresponding floor.

 

-Each floor, except the first floor and top floor has two buttons, one to request and up-elevator and one to request a down-elevator. These buttons illuminate when pressed. The illumination is canceled when an elevator visits the floor and then moves in the desired direction.

 

- When an elevator has no requests, it remains at its current floor with its doors closed.

 

1) Draw a use case diagram for the elevator.

2) Draw a class diagram for the elevator.

 

Question 11

 

Using the system description below create the following:

 

a) A use case diagram

b) A class diagram including all necessary attributes/operations

c) An object diagram for the following scenario:

The key is in the ignition, and the car is moving at 20 mph. The system has not been altered by the driver since the car started moving

 

System description: 2001 Volkswagen Jetta door locking/unlocking mechanism

 

System Components:

 

 

System Operation - General

 

 

        a) locked

        b) unlocked

        b) open (door is physically open)

 

System Operation - unlocking and opening

 

a)If all doors are locked - unlock the driver's door

b)If the driver's door is unlocked - unlock all doors

 

a)If the locked - unlock the individual door

b)If unlocked - open the door

 

System Operation - locking

 

 

 

System Operation - Special Cases

 

Question 12

 

Develop a state diagram for the following description:

 

A computer can be powered up, shut down, restarted, running idle, or crashed.  The running idle state of a computer is based upon two things:  The network connection can be up or down and the processor can be running or suspended (concurrently).

 

Assume the computer can crash at any time after it is started.

 

Use substates (concurrent or sequential) when applicable.  Be sure to include all necessary components (events, guards, actions, etc.)

 

Question 13

 

You are in an elevator. The elevator services 3 floors.  The behavior of the elevator is such that it tries to be efficient. That is, if the elevator is going up from floor 1 to service floor 3, it won’t stop for a down signal on floor 2.

 

However, that behavior changes if an Emergency switch is set. If the switch is turned, the elevator does not behave efficiently, but rather, does not respond to any external service signals. It only responds to floor button events. If the switch is turned on, the elevator stops and waits for a floor to be pushed and one when one is pushed, it immediately goes to that floor. When the switch is turned off, the elevator resumes normal operation.

 

 

Questions

1. Describe a possible scenario for this elevator

2. Draw the statechart diagram

 

Question 14

 

You are given a tape recorder/ radio.  There is one button to toggle the radio on and off and 6 tape recorder buttons (play, record, FF, RW, pause, stop).  The record button is inlayed in the play button, so the play button must be pushed along with the record button.  The tape player is old, and the play button can be activated at the same time as FF or RW (to make that high pitch squealing noise).  When the radio is on, the recorder records the radio, and when it is off, it records from a built in microphone.  Draw a Class Diagram or Statechart Diagram to represent this tape recorder.

 

Question 15

 

The North Campus visitor parking lots use electronic parking meters which consist of:

 

- an LCD display

- a numeric keypad

- a coin slot

- a bill acceptor

- a green confirmation button

- a red cancellation button

- a receipt printer.

 

When not in use (i.e. idling), the parking meter displays the current time of day and a prompt to enter the space number.  If the user types in a parking space number on the numeric keypad, the prompt displays the space number and the current time.  The user can then insert a combination of coins and bills.  As money is inserted, the current time display increments to indicate the time at which the meter will expire.  The user completes the transaction by pressing the green button, at which time a receipt is printed and the machine returns to idle.  At any time, the user may press the red button to cancel the transaction, which refunds any money that was inserted and returns the machine to idle.  You may assume that:

 

·         valid parking space numbers are in the range [1, 200]

·         parking costs $0.80 per hour

·         parking is enforced 24 hours per day

 

Draw a statechart diagram for the parking meter.  State any other assumptions that you make.

 

Question 16

 

You are hired at a software company that produces interactive playing card games. Your first project is to recreate the classic game "Solitaire". The programmer you are replacing left the company with some code consisting of the following classes, without implementation details:

 

·         Card

·         Deck

·         CardStack

·         CardBin

·         ScoreKeeper

 

You are asked to take these classes and finish the project using them.  You must use at least these 4 classes (the boss is fickle, and doesn't like to see work go to waste).

 

Create a UML Class Diagram, and a UML Use Case Diagram that describes the complete game of "Solitaire".

 

Rules for "Solitaire"

 

"Solitaire" is played with a normal four suited, 52 card deck of playing cards.

Six Stacks of cards are placed in the center of the gaming area. The first deck holds on card, face up. The second deck holds one card face down and another card on the top face up. The third deck has two cards face down, and another card on the top, face up. Etc.

A Deck is composed of all the remaining cards. When selected, the deck reveals the top card, which is placed on a discard stack. Only the top card can be played. When removed, the previously revealed card, now at the top of a discard stack, if one exists, can be played. If the deck is empty, any cards in the discard stack are replaced face down in the deck, in the opposite order they were revealed. Cards are played by placing one of the face up cards from either the deck or the gaming area on top of a face up card that is exactly one denomination higher, and of an opposite colored suit. Any face up cards above the card successfully moved are transferred along with that card.

 

If any stack has a face down card at the top, that card will be turned face up immediately. If there is an empty stack in the gaming area, only a King may be moved to occupy that stack. Points are scored if this is accomplished.  Cards can be removed from these stacks if placed into one of four scoring bins. A scoring bin is a stack of cards for one particular suit. It will accept a card if the bin is empty, and the card is an Ace, or if the card is one denomination higher, and the same suit as the card that is currently on the top. Points are scored for a successful placement of a card in a scoring bin.  The game is ended, and points are awarded when the deck, discard stack, and stacks in the playing area are complete.

 

Question 17

 

Your job is to design a relatively complex microwave oven.  Its features are:

 

·         Time cook entry

·         Optional Power setting

·         Set time

·         5 preset times

·         Stop button

·         Start button

·         Open door button

 

Functionality-wise,

 

 

 

a. Please create a Use-case and a Class diagram modeling the microwave’s behavior

 

b. Create a State-chart diagram for a single case of the user cooking something.  Use the longest case you can think of

 

c. Create an object diagram of the program in use.  What functionality did you add to your class diagram if any?

 

 

Question 18

 

You are the ruler of the Island Republic of Computer Scientist Ruling the World (IRCSRW). A large over powering country who likes to extend its arms into foreign affairs doesn't want your military to exist. Invasion is imminent. Your friend that you appointed as supreme chancellor of defense can build ballistic missiles, but he can't code worth crap. You, being the benevolent ruler of a population of maybe 20 people, all cool people by the way, want to have your missiles do precisely what they were made for.

 

The software is a simple command prompt driven program that initially prompts the user for a password. The user is given 3 chances for a correct password and if all 3 chances are blown the system locks down for 24 hours. After the password has been verified correctly a print out of options is displayed. The options are as follows:

 

1.     Select target location;

2.     Select launch location (since you have a few silos);

3.     Load missiles into launch bay;

4.     Launch missiles;

 

After selecting option 1, the next screen prompts you for longitude and latitude coordinates. The program should verify that you are indeed shooting a legit place on Earth and not out of L&L range (i.e., 91 degrees north is not valid).

 

After selecting option 2, the next screen prompts you for deciding launch from silos 1 through 4.

 

After selecting option 3, the screen flickers to cameras showing the missiles being loaded. The screen stays on this camera view until the missile is completely loaded.

 

After selecting option 4, the program prompts you for current launch code validation which should be obtained from the emergency secret code box. If the code is not validated, the entire system is reset and the program is locked down for 24 hours. If the code is verified, the next screen just prompts one more time before you start the next world war. Once selected, the program exits, the missile is launched, and you have to start over from step one.

 

Your mission, since you're the only person on the island that can code, is to make a Use Case Diagram, Class Diagram, and Statechart Diagram for IRCSRW's lines of defense. We're counting on you.

 

 

Question 19

Draw a statechart diagram for the wristwatch shown below.  Watch can not be manually set.  When powered up it will start at 12:00 and 00 seconds.

 

 

 

 

 

 

 

 

Question 20

 

Adaptive Traffic Control System

 

        The City of Ann Arbor has invested millions of dollars revamping the traffic signals. They have sensors in ground to detect the flow of traffic in every direction and sensors to detect vehicles in the turning lanes. During the day, the traffic lights are pretty conservative. A typical cycle will be something like this. Given intersection with the picture shown below, traffic in direction A will get a green light for 25 sec. and an amber light for 5 sec. and B a red light for 30 sec. Before the flow of traffic changes, the system senses if a car is in the left turn lane, if so they will get a green left turn light for either some set duration or until there are not more car turning left. Then B traffic will get a green light for 25sec. and an amber light for 5 sec. As well the A traffic will get a red.  After 10pm, the sequence changes, since Street A is the major street, they will keep a green light unless a car from A needs to make a left turn or a car from traffic B needs to get across or turn. So when a car approaches on street B after sitting at the light for 5 sec, the green light for A turns amber and then red. The light for B turns green until all of the traffic waiting at B passes or some preset duration. Then resuming normal flow of A traffic.

 

Question, draw a state diagram for this model, for either the day mode or night mode.