1 / 8

OO Design Overview and Exercise

OO Design Overview and Exercise. OO Design Activities. Identifying the objects Defining the objects’ responsibilities Services Attributes Discovering relationships among objects. Identifying the Objects.

Download Presentation

OO Design Overview and Exercise

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OO Design Overview and Exercise

  2. OO Design Activities • Identifying the objects • Defining the objects’ responsibilities • Services • Attributes • Discovering relationships among objects

  3. Identifying the Objects • A common (but not necessarily thorough) method for identifying objects is to locate all nouns or adjective/noun combinations in the problem description. Some or all of these nouns may be objects. Others may actually be object attributes.

  4. Defining the Objects’ Responsibilities • A common (but not necessarily thorough) method for defining object operations is to locate all verbs/actions in the problem description. • From these operations and from the nouns and adjective/noun descriptions, define the objects’ attributes.

  5. Simplified BlackJack An interactive program to play the game of blackjack. The computer acts as the dealer and will play against the user (like in a casino). The object of the game is to get your cards as close to 21 without going over. Face cards count 10, Aces count 11. A hand begins with the player and dealer each getting two cards. The player asks for up to 3 more cards, one at a time, from the dealer until he wishes to stop or the total is over 21. The dealer then draws up to 2 more cards, one at a time while the total of his hand is less than 21. Once the dealers hand reaches 17 or higher, no more cards are dealt. If the dealer’s hand and player’s hand have the same value, or both are over 21, the hand is a draw. Otherwise, the hand closest to 21 wins. Hands are dealt repeatedly until there are not enough cards in the deck to deal a complete hand.

  6. Simplified BlackJack An interactive program to play the game of blackjack. The computeracts as the dealer and will play against the user (like in a casino). The object of the game is to get your cards as close to 21 without going over. Face cardscount 10, Acescount 11. A gamebegins with the player and dealer each getting two cards. The playerasks for up to 3 more cards, one at a time, from the dealer until he wishes to stop or the total is over 21. The dealer then draws up to 2 more cards, one at a time while the total of his handis less than 21. Once the dealer’s handreaches 17 or higher, no more cardsare dealt. If the dealer’s hand and player’s handhave the same value, or both are over 21, the handis a draw. Otherwise, the hand closest to 21 wins. Hands are dealt repeatedly until there are not enough cards in the deck to deal a complete hand.

  7. computer dealer user casino object game cards face cards Aces player total hand dealer’s hand player’s hand value deck complete hand computer acts computer will play get your cards as close to 21 face cards count 10 Aces count 11 a game begins getting two cards player asks for up to 3 more cards he wishes to stop total is over 21 dealer then draws total is less than 21 dealer’s hand reaches 17 or higher no more cards are dealt hand is a draw wins both have the same value both are over 21 hands are dealt are not enough cards in the deck

  8. Relationships Among Objects Three most common forms of object interaction: • association (“uses a”) • uses another object type as a function input • returns another object type • defines another object local to a function • aggregation/composition (“has a”) • inheritance (“is a”)

More Related