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

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.

Design

On line chess

Show how you would design the following system using UML class diagrams and design patterns.

A chess playing program allows multiple users to play chess against a centralized server. Users can save their games and resume them later.

A Workflow Management System (WMS)

Your team is developing an application that will create, browse, and update student records that will be stored in some sort of database. A student record contains a last name, first name, unique id number, major, and a GPA. Using the DAO and Transfer Object patterns develop an interface that the application can use to access the database. Your DAO should allow searches that return multiple records. (Hint: a null field matches anything.)

Spread Sheet Design

A spread sheet consists of a grid of cells:

Cell[][] sheet = new Cell[M][N];

Each cell has a value that's updated by an update method. The update method may refer to the values of other cells in the sheet to compute its value. A cells update method can be called by the user. It is also called automatically each time any of the cells it depends on are updated.

How would you design and implement the Cell class using the Publisher-Subscriber Pattern?

A Student Tracking System (STS)

After a student has been admitted to Northern California University, a student record is created in a database. This record holds the student's name, identification number, major, and grade point average. It also holds a list of all semesters the student attended. For each semester, there is a list of courses the student took. Each course has a department, number, title, number of units, and of course the grade the student received. Faculty and administrators may view and update student records. A student may view his own record.

Draw a domain model using a class diagram.

Draw a use case diagram.

How would you design STS? Consider using the following patterns: Three-Tier architecture, Model-View-Controller, Proxy, Gateway, and Transfer Objects.

Implement a student record in Java.

A Patient Tracking System

When a patient checks into the hospital, the hospital administrator creates a patient record in the Patient Tracking System (PTS). The record initially holds the patient's name, the name of his insurance company, his policy identification number, and the name of his doctor. After the patient has been admitted, his doctor places orders for tests on the patient's record. These tests are performed by technicians, who record the results in the patient record. Next the doctor orders treatments by placing them in the patient record. Nurses perform the treatment. When the patient checks out of the hospital, the administrator adds up the costs for the tests and treatments and generates an invoice.

Draw a UML class diagram showing how you would model this domain.

Write an interface for a DAO that transfers patient records between a database and the PTS using transfer objects.

A Claim Processing System

A claims processing system (CPS) provides a user interface that allows a claims adjuster to view and update policies, and to create, update, and view claims. When a claims adjuster receives an accident report, he first determines if the accident will be covered by the claimant's policy. If so, he creates a claim that describes the date of the claim and the policy number of the claimant. After the adjuster receives three repair estimates and a police report, a check is issued to the claimant, the claim is closed. The amount of the check is determined by the business rule:

lowest estimate - deductable

If, according to the police report, the claimant was at fault, then the policy premium is increased according to the business rule:

premium += riskFactor * premium

where

riskFactor =
   (#claims where the claimant was at fault)/# of years driving

Represent the description just given with a UML activity diagram.

Draw a UML diagram showing how you would design this system. Consider using the Model-View-Controller and DAO patterns.

Write an interface for a DAO that uses transfer objects to move claims and policies between the CPS and the database.