title: UML Class Diagram for Strategy Pattern
body: <p>I have an exam in a couple of hours and I am trying to solve sample questions for it. I couldn't find a solution to following question. </p>
  
  <blockquote>
    <blockquote>
      <p>Draw a class diagram corresponding to the following situation:</p>
      
      <p>A grocery store (e.g., a supermarket) sells items. There are two types of items: edible
      (i.e., any item that can be used as food) and non-edible. Some items are sold by weight,
      and some are sold per unit. Some items are taxable, while others are not. Some items
      have special prices when sold in groups (e.g., 2 for $3). A purchase may contain many
      items.</p>
      
      <p>In your class diagram, show only the classes/abstract classes/interfaces, associations,
      and multiplicities for the associations. Do not include any operations! Clearly indicate
      interfaces and abstract classes (if any) in your design.</p>
      
      <p>Furthermore, your design should be as 
      <strong>flexible</strong> as possible. In particular, you need to
      pay attention to the following points:</p>
      
      <p>1) An item is either edible or not and this fact does not change during the lifetime of
      the item, whereas the pricing strategies may change during the lifetime of the item.</p>
      
      <p>2) Each pricing strategy is associated with a certain set of operations. For example,
      for the taxing strategy, whether or not an item is taxable, we may have an operation
      that computes the tax (this function can then return 0 for non-taxable items)</p>
      
      <p>3) Although the set of operations for a pricing strategy stays the same, the ways those
      operations are handled may change over time. For example, the way we compute
      taxes for edible and non-edible items may differ over time.</p>
      
      <p>4) Although the set of operations for a pricing strategy stays the same across different
      items, we may want to implement those operations in different ways for different
      items. For example, we may want to compute the tax differently for oranges and
      apples.</p>
    </blockquote>
  </blockquote>
  
  <p>I tried something like this thinking that it could suit to the Strategy Design Pattern, but I am not sure at all. </p>
  
  <p><img src="https://i.stack.imgur.com/RJBKQ.png" alt="enter image description here"></p>