Welcome to the engineering team at the Gilded Rose! As you know, we're an inn that buys and sells only the finest goods. Our goods are constantly degrading in quality as they approach their sell-by date, so we have an inventory system that keeps track of these data.
We need you to add a new feature to our system so that we can begin selling a new category of items. However, the code is a mess, and it will be difficult to add the new feature unless you first refactor the existing code.
So your task is twofold: refactor the inventory system, then add the new feature.
Here are the basics of our system:
Pretty simple, right? Well, this is where it gets interesting:
To pave the way for the new feature, refactor the existing code and make it easier to change.
Feel free to make any changes and add any new code as long as everything still works correctly (i.e., as long as the tests for existing features still pass).
Note: you can assume that items always start with a valid quality. In other words, the automated tests don't check what happens when an item has an initial quality above the maximum, or when a Sulfuras has an initial quality other than 80.
We have recently signed a supplier of Conjured items. Your job is to add the following rules to our system:
Sign up to Exercism to learn and master Ruby with 20 concepts, 120 exercises, and real human mentoring, all for free.