UML Class Diagram for Strategy Pattern -


i have exam in couple of hours , trying solve sample questions it. couldn't find solution following question.

draw class diagram corresponding following situation:

a grocery store (e.g., supermarket) sells items. there 2 types of items: edible (i.e., item can used food) , non-edible. items sold weight, , sold per unit. items taxable, while others not. items have special prices when sold in groups (e.g., 2 $3). purchase may contain many items.

in class diagram, show classes/abstract classes/interfaces, associations, , multiplicities associations. not include operations! indicate interfaces , abstract classes (if any) in design.

furthermore, design should flexible possible. in particular, need pay attention following points:

1) item either edible or not , fact not change during lifetime of item, whereas pricing strategies may change during lifetime of item.

2) each pricing strategy associated set of operations. example, taxing strategy, whether or not item taxable, may have operation computes tax (this function can return 0 non-taxable items)

3) although set of operations pricing strategy stays same, ways operations handled may change on time. example, way compute taxes edible , non-edible items may differ on time.

4) although set of operations pricing strategy stays same across different items, may want implement operations in different ways different items. example, may want compute tax differently oranges , apples.

i tried thinking suit strategy design pattern, not sure @ all.

enter image description here

first there store, can grocery store. store has 2 type of objects: items , purchases. without items and/or purchases store stop exist. items exist without store (they must delivered store instance), purchases belong store itself. why there aggregational relationship between store , item, yet compositional relationship between store , purchase.

items have features, name, edible, taxable, weight , unit. did not implement characteristics of item, idea there. there lot of ways sell items. there might more strategies used @ same time. situation decorator pattern designed. can add several strategies dynamically @ runtime. decorating item - interface, because associated item, because change in way sell finds cause in item. has association class purchase, not part of purchase. every item sold belongs specific purchase. can have state not being sold yet. why multiplicity of purchase 0-1. in boils down this:

class diagram of items sold in store


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -