title: Constructing and Designing Class Diagrams
body: <p>I have the following scenario where I have to design a class diagram : </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>The points need to be considered are :</p>
  
  <ul>
  <li>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.</li>
  <li>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)</li>
  <li>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.</li>
  <li>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.</li>
  </ul>
  
  <p>I know it must be a strategy design pattern. I am thinking of doing a <i> PricingStrategy </i> interface and implement the strategies but I am not sure of them. Moreover, I may create an Item super class and Edible and Non-Edible Items can inherit the class however nothing is clear in my head, any help is appreciated.</p>