1 / 12

Ice Cream Model

Ice Cream Model. If( f.equals( “vanilla” ) ){ // do something }else if ( f.equals( “chocolate” ) ){ // do something else } Cream aCream = new Cream(); aCream.setFlavor( “vanilla” );. Cream. - flavor: String - toppings: String - price: float … . + setFlavor( f: String ): void.

DoraAna
Download Presentation

Ice Cream Model

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. Ice Cream Model • If( f.equals(“vanilla”) ){ // do something}else if ( f.equals(“chocolate”) ){ // do something else} • Cream aCream = new Cream();aCream.setFlavor(“vanilla”); Cream - flavor: String - toppings: String - price: float … + setFlavor(f: String): void Let’s not do this. Have your complier work harder!

  2. If( f.equals(“vanilla”) ){ // do something}else if ( f.equals(“chocolate”) ){ // do something else} • Cream aCream = new Cream();aCream.setFlavor(“vanilla”); Cream - flavor: String - toppings: String - price: float … + setFlavor(f: String): void If( f.equals(Flavor.VANILLA) ){// do something } else if( f.equals(Flavor.VANILLA) ){// do something else } Cream aCream = new Cream(); aCream.setFlavor(Flavor.VANILLA); Cream <<enumeration>> Flavor - flavor: Flavor - toppings: String - price: float … 0..* VANILLACHOCOLATESTRAWBERY LIME ORANGE 1 + setFlavor(f: Flavor): void

  3. Cream <<enumeration>> Flavor 0..* 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE 0..* + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void <<enumeration>> Topping 0..* NUTSEXTRACHOCOLATESTRAWBERRYJEERRY

  4. Cream <<enumeration>> Flavor 0..* 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY Class diagram + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void myCream: Cream vanilla: Flavor Flavor.VANILLA Object diagram yourCream: Cream chocolate: Flavor Flavor.CHOCOLATE : Cream strawberry: Flavor Flavor.STRAWBERY

  5. Now, We can Make these Ones. Cream <<enumeration>> Flavor 0..* 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE 0..* + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void <<enumeration>> Topping 0..* NUTSEXTRACHOCOLATESTRAWBERRYJEERRY

  6. How about these ones? http://www.graniteschools.org/jr/eisenhower/images/memorie%20pics/world_records/Tallest_Ice_Cream_Cone.jpg

  7. up 0..1 Cream <<enumeration>> Flavor 0..* 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE down 0..* 0..1 + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void Class diagram <<enumeration>> Topping 0..* NUTSEXTRACHOCOLATESTRAWBERRYJEERRY 3rdCream: Cream vanilla: Flavor up Flavor.VANILLA Object diagram down 2ndCream : Cream chocolate: Flavor up Flavor.CHOCOLATE down 1stCream : Cream strawberry: Flavor

  8. In this case…

  9. 1 <<enumeration>> Flavor Cream 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE 0..* - scoops 0..* 0..* + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void <<enumeration>> Topping 0..* NUTSEXTRACHOCOLATESTRAWBERRYJEERRY - cone 1 0..1 Cone 0..*

  10. How about these cases? Cone or cup Size of cone/cup

  11. <<enumeration>> Flavor Cream 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE 0..* - scoops 0..* 0..* + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void <<enumeration>> Topping 0..* - scoops 0..* NUTSEXTRACHOCOLATESTRAWBERRYJEERRY - cup 0..1 0..1 - cone 0..1 0..* Cup Cone 0..* 0..* <<enumeration>> Size SMALLMEDIUM LARGE 1 - size

  12. <<enumeration>> Flavor Cream 1 - flavor: Flavor - toppings: Topping[] - price: float … VANILLACHOCOLATESTRAWBERY LIME ORANGE 0..* - scoops 0..* 0..* + setFlavor(f: Flavor): void + setToppings(t: Topping[]): void <<enumeration>> Topping 0..* 1 - base NUTSEXTRACHOCOLATESTRAWBERRYJEERRY Base (Lower Part) 0..* - size: Size - scoops: Cream[] - price: float - topping: Topping … - size 1 0..1 <<enumeration>> Size SMALLMEDIUM LARGE Cup Cone 0..*

More Related