O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a fridge

To truly understand the usefulness of separating usecases from entities, we might also want to add another entity, the  fridge. In usecases like add/remove grocery item, we could change the fridge's status (empty/non-empty) whenever an item is added/removed. To achieve this, we will add entities::Fridge to our system, and call the update of its isEmpty method when a grocery item has been added/removed, and before returning the success/failure of the respective use case.

Try adding entities::Fridge as described, and augment usecases::AddGroceryItem and usecases::RemoveGroceryItem accordingly. In the use case tests, you will likely need to add a few scenarios to take into consideration what happens to the fridge (and the groceries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required