samedi 30 janvier 2016

class design in a little java, a little pattern?

I am reading A Little Java, A Few Patterns recently, Chapter 3 introduce Pizza class and some its subclasses. It looks strange to me that Crust, Cheese and Olive class are defined as subclass of Pizza

Apparently, those are ingredients of a pizza, and the relation between those ingredients and a pizza is has a not is a.

So why those ingredients class are defined as subclass of Pizza ?

FYI, code snippet below is the class structure used in this book.

Aucun commentaire:

Enregistrer un commentaire