Glenn D' Blank and Fang Wei - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Glenn D' Blank and Fang Wei

Description:

In Eclipse, draw a class for your first class. R. R. M. M. A. A. A. A. A. A. A. A. A. A. A. A. A. A ... Design a movie ticket vending machine ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 10
Provided by: designfir
Category:
Tags: blank | eclipse | fang | glenn | movie | tickets | wei

less

Transcript and Presenter's Notes

Title: Glenn D' Blank and Fang Wei


1
Object-oriented design from problem
descriptionto class diagram
  • Glenn D. Blank and Fang Wei
  • Computer Science Engineering Department
  • Lehigh University, Bethlehem, PA, USA

With support from the National Science
Foundation (Grants No. EIA-0087977 and 0624553)
and the Pennsylvania Infrastructure Technology
Alliance
2
(No Transcript)
3
From problem description to class diagram (in
eight steps)
  • 1. Read the problem description at least twice.
  • Ask questions about anything you dont understand
    or needs more explanation.
  • The ATM verifies whether the customer's card
    number and his her PIN (a number) are correct. If
    it is, then the customer can check the account
    balance, deposit cash, and withdraw cash.
    Checking the balance simply displays the account
    balance. Depositing asks the customer to enter
    the amount, then updates the account balance.
    Withdraw cash asks the customer for the amount to
    withdraw if the account has enough cash, the
    account balance is updated. The ATM prints the
    customers account balance on a receipt.

4
Sentence grammar analysis
  • 2. Put an S next to each subject, a V next to
    each verb and an O next to each object.
  • The ATM verifies whether the customer's card
    number and PIN are correct.
  • S V
    O O O
  • If it is, then the customer can check the
    account balance, deposit cash,
  • S V
    O V O
  • and withdraw cash. Checking the balance displays
    the account balance.
  • V O S
    O V O
  • Depositing asks the customer to enter an amount,
    then updates the balance.
  • S V O V
    O V
    O
  • Withdrawing asks the customer for the amount to
    withdraw if the account has
  • S V O
    O V S
    V
  • enough cash, the balance is updated. The ATM
    prints the customers
  • O S V
    S V O
  • account balance on a receipt.
  • O O

5
Analyze subjects and objects
  • The ATM verifies whether the customer's card
    number and PIN are correct.
  • S V
    O O OIf it
    is, then the customer can check the account
    balance, deposit cash, and withdraw cash.
  • S
    V O V
    O V O
  • Checking the balance simply displays the account
    balance.
  • S O
    V O
  • Depositing asks the customer to enter the
    amount, then updates the account balance.
  • S V O
    V O V
    O Withdraw cash asks the customer
    for the amount to withdraw if the account has
    enough cash,
  • S O V O
    O V
    S V O
  • the account balance is updated. The ATM prints
    the customers account balance on a receipt.
  • O V
    S V
    O O
  • 3. Analyze each subject and object as follows
  • Does it represent a person performing an action?
    Then is an actor, R.
  • Is it also a verb (such as deposit)? Then it
    may be a method, M.
  • Does a subject take a simple value, such as
    color (string) or money (number)? Then it is
    probably an attribute, A.
  • Which remaining unmarked noun occurs most
    frequently? Make it C for class.
  • In Eclipse, draw a class for your first class.

A
C
A
R
A
A
R
A
M
A
A
A
A
A
M
R
R
A
A
A
M
A
A
C
6
(No Transcript)
7
Analyze methods and attributes
  • 4. If a verb has a non-actor object its a
    method, M
  • 5. Distinguish attributes, A, and parameters, P
  • If it doesnt distinguish instances of a class or
    store information about objects, its probably a
    parameter, not an attribute
  • Add attributes to a class in the UML class
    diagram
  • Add methods in the class diagram
  • While adding methods, include the parameters
  • See the return type of your methods
  • get methods take the type of the attribute
    returned
  • set methods take void return type
  • compute methods take the type of the computed
    value
  • Methods that answer true/false questions take
    boolean type

8
Any more classes?
  • 6. If any remaining classes has no attributes,
    its probably an attribute of another class
  • 7. Otherwise, add another class to the diagram
    and go back to step 4 (analyze its methods and
    attributes)
  • 8. Draw association links between the classes
  • Check your design to make sure it makes sense!

9
Lab exercise Design a movie ticket vending
machine
The movie ticket machine displays the movie
title, displays the show time (e.g. 2006-11-16
700pm), and displays the price of a ticket
(e.g. 8.50). A customer enters money (e.g. 20.50)
into the machine. The machine displays the
customers balance (e.g. 20.50). The customer
enters the number of tickets (e.g. 1) into the
machine. The machine prints the tickets, and
returns the customers balance (e.g. 12.00).
Print tickets also tracks the number of available
seats in the theater so it can tell the customer
when the available seats are sold out.
Write a Comment
User Comments (0)
About PowerShow.com