Welcome to your fifth and final unit for this course, focused on practicing the principles of Test Driven Development (TDD) using Scala and ScalaTest. We’ll continue building our ShoppingCart
system by integrating more sophisticated features into the class.
In this course, the emphasis is placed on hands-on practice, where you’ll receive requirements through tests, one at a time. Your task is to write tests AND implement code that makes each test pass, simulating a real-world TDD environment. In previous lessons, tests were provided to guide you, but now it’s your turn to define them!
Remember to apply the core concepts of the Red-Green-Refactor cycle while completing these coding exercises. Ask questions if you need clarification!
These requirements introduce more sophisticated capabilities for the ShoppingCart
class, focusing on robust item management, discount application, and quantity handling. These features will challenge you to apply TDD principles effectively and enhance the system's functionality.
Let's take a look at the final set of requirements.
-
Description: The cart should enforce a maximum quantity limit of
10
for a single type of item, preventing more than this allowed amount from being added. -
Details:
- Utilize the
addItem(product: Product, quantity: Int)
method to add items to the cart.
- Utilize the
