Projects/Exercises

Activity Diagrams

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.

Use Case Diagrams

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.

Class Diagrams

Translate the following domain descriptions from English into UML class diagram models. Look for important concepts and relationships. Look for generic relationships such as "is a" "has a" "uses a" and "contains".

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.

Account holder is a role played by an actor. An actor is a person or organization. Actors have names, contact information, and identification numbers. An account holder has a password.

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 players.

 

Sequence Diagrams

A yellow pages server maintains a table of services along with agents that perform those services. When an agent wants a service it gets a list of agents who perform that service from the YPS and sends a request for proposal to each one.