No, it actually doesn't.
class Item
def add_to_cart(cart)
cart.increase_total(this.price)
This is where the trouble is. It is not the inheritance, it is the add_to_cart method not being in the correct class. If this instead had been class Cart
def add(item)
.. add item to some collection of stuffs implementing price().
def sum()
.. calculate total sum.
then the whole problem evaporates. If your code reads do_something_to_foo(foo), then very often usually it really ought to be foo.do_something()Inheritance can be ok when used sparingly, but this example is not one of those.