Object-Oriented Analysis Labs

Refactoring Models

Repair the flaws in the following bad models.

Domain Modeling: Concepts, Entities, and Relationships

Using text analysis, analysis patterns, and common sense, translate the following domain descriptions from English into UML class and object diagrams.

Recall that a class diagram models general concepts (T-Box), while an object diagram models assertions about specific objects in a specific domain (A-Box).

Account Management

Banks manage accounts and account holders. Every account is held by an account holder. Every account holder holds one or more accounts. An account has a balance of type Money, an identification number, and a statement. A statement is a list of transactions. A transaction represents a transfer of funds to or from some other account at a particular time.

Using your class diagram as a template, translate the following assertions into an object diagram:

Smith and Jones are account holders at Central Bank. Each has one account. Smith's accoount has a balance of $1000. Jones' account has a balance of $500. On June 1, 2007 $500 was transferred from Smith's account to Jones' account.

Ticket Brokers

An outlet sells tickets to events. An event takes place in a venue at a certain time. A venue has zero or more seats. A ticket has a price and a seat. A competition is an event. A performance is an event.

A performance has a description. Plays, concerts, and dances are performance descriptions. A play has a playwright and a cast of characters. Each character is played by an actor. Playwrights and actors are persons.

 Organizational Hierarchies

A league has many conferences. A conference has many divisions. A division has many teams. A team has many positions. A position is played by a player. A player has a name and a number.

Using your class diagram as a template, translate the following assertions into an object diagram:

The National Football Leagues (NFL) is organized into the American Football Conference (AFC) and the National Football Conference (NFC). Both leagues have Eastern, Central, and Western divisions. The Oakland Raiders and the Kansas City Chiefs are teams in the Western Division of the AFC. Ken Stabler, #12, is the quarterback for the Raiders.

The Web

A computer hosts a web server that manages many resources. These resources include documents, applications, and services. Each resource has a method called exec that returns a document as an output. (For a document this method returns the document itself.) The web server associates a unique URL with each resource it manages and provides a method called getResource, which takes a URL as input and produces a document as an output.

Using your class diagram as a template, translate the following assertions into an object diagram:

The computer mojo.aua.am runs an Apache web server that manages two web pages (docs/index.html and docs/info.html) and a web application (app/sql).

Health Care

Patient, Doctor, and Nurse are some of the roles people play in a hospital. Doctors prescribe tests, nurses administer tests, and patients take tests. A test is administered on a specific date. There are two types of tests: measurements (temperature, for example) and categorizations (blood type, for example). The result of a measurement is a quantity. A quantity is a number together with a unit (degrees centigrade, for example). The result of a categorization is a category (A, B, AB, O, for example.)

Using your class diagram as a template, translate the following assertions into an object diagram:

Joe Smith is a patient at Mercy Hospital. On January 1 his temperature was 40 degrees centigrade. On January 2 it was 37.

Domain Modeling: Workflows

Model the following procedure with a UML Activity Diagram.

How a Bill Becomes a Law

The US Senate and the US House of Representatives follow similar procedures for making new laws. In the house a member introduces a proposed law, which is called a bill. The clerk assigns a number to the bill. The printing office makes copies of the bill. The Speaker of the House refers the bill to a committee. The committee can kill the bill by ignoring it or they can vote on it. If it passes, the bill goes to the Floor for a vote. If it passes it goes to the Senate for a vote. If it passes, it goes to the President. If the president signs it, it becomes a law. If the president vetoes the law, it goes back to the Senate and the House where a 2/3 majority is needed to override the veto. If the president does nothing, then the bill becomes law after 10 days unless congress is not in session. In this case the bill dies. This is called a pocket veto.

Criminal Procedure

In a typical felony criminal preceding the defendant (i.e., the person arrested) enters a plea of guilty or not guilty. If the plea is guilty, the judge sentences the defendant and the defendant serves his sentence. If not guilty, a trial date is set and bail is set. During the trial the prosecutor presents evidence, then the defendant (i.e., the defendant's attorney) presents evidence. Next, the jury deliberates and makes a verdict. If the verdict is not guilty, then the judge releases the defendant. If guilty, then the judge sentences the defendant. If the defendant believes the trial was unfair he may appeal the case, otherwise he serves his sentence. If he appeals, the appellate court my overturn the conviction or uphold the conviction. If the conviction is upheld, the defendant serves his sentence, otherwise the appellate court releases the defendant.

Procedure for buying a house

The buyer finds a house and makes an offer. The seller may accept the offer or may make a counter offer. If the seller makes a counter offer, the buyer may accept the counter offer or make another counter offer. This repeats until either the buyer or seller rejects the counter offer or accepts the counter offer. After an offer or counter offer has been accepted, the buyer simultaneously applies for a loan and a home inspector inspects the home. If the loan is approved and if the inspections pass, the escrow officer conducts a title search. If the seller actually holds the deed, the escrow officer transfers the deed to the buyer and transfers the buyer's money to the seller.

Procedure for running a program

A program as a procedure

Draw activity diagrams that model the following methods:

double tax(double income) {
   if (income < 0) error("invalid income");
   if (income < 1000) return 0;
   if (income < 20000) return 0.1 * income;
   if (income < 30000) return 0.2 * income;
   if (income < 50000) return 0.3 * income;
   return 0.5 * income;
}

double add(double[][] matrix) {
   double result = 0;
   for(int row = 0; row < matrix.length; row++) {
      for(int col = 0; col < matrix[row].length; col++) {
         result = result + matrix[row][col];
      }
   }
   return result;
]

A Job Processing Procedure

A Peugot assembly line begins by assembling the chassis. Next, the interior team bolts the seats to the chassis, then the steering column. At the same time the engine team mounts the engine to the chassis, then tests the engine. If the engine fails the test, it must be remounted. Meanwhile, the chassis for the next car is being assembled. After the engine and interior, are installed, the body is bolted to the chassis. Draw an activity diagram showing this workflow.

Requirements Modeling

Elevator

The control panel on an elevator allows a passenger to select a floor, open the door, close the door, and declare an emergency, which sounds an alarm at the elevator repair company's local office. Once a floor is selected, the elevator closes the doors, then begins to move, either up or down. When the elevator arrives at the floor it stops and opens the doors. In addition, an elevator repairman can remotely run a diagnostic on an elevator and command the elevator to return to the ground floor. Draw a use case diagram for this elevator.

Web Browser

A web browser (like Netscape or Internet Explorer) allows users to download web pages from web servers. The downloaded page is displayed and cached by the browser. (The browser always consults the cache when a page is requested.) Users can also display the previous and next pages in the cache (which is organized sequentially). Users can stop a download and reload a page from the server (bypassing the cache). Draw a use case diagram for a web browser. In all cases where the desired web page can't be found, a special "error" web page is displayed.

Elaborate on the "download web page" use case. You only need to provide one sentence descriptions of each scenario. Except draw a sequence diagram showing the successful download scenario.

Account Management

An on-line banking system allows users to log in and out, open and close accounts, view recent account activities, transfer funds between accounts, and to pay bills to creditors that provide servers that accept online payments. Draw a use case diagram for the bill payment system and elaborate on the transfer funds use case.