Introduction to the Shopping Cart System

Welcome to your third unit of this course dedicated to practicing Test Driven Development (TDD) utilizing Scala and ScalaTest. We will begin building a new system; this time, we’ll focus on creating a shopping cart system with a variety of features.

In this course, 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 Scala 3 code that makes each test pass, simulating a real-world TDD environment. Unlike previous exercises, where tests were supplied, this time you're in charge!

Remember to utilize the core concepts of the Red-Green-Refactor cycle while working through these exercises. Assistance is available, so don't hesitate to ask for help.

Requirements for ShoppingCart Class

The following requirements outline the foundational functionality of the ShoppingCart class, providing step-by-step guidance to build and test its key features while practicing TDD principles in Scala.

Each requirement focuses on a specific aspect of the shopping cart's behavior, ensuring a comprehensive and modular approach to its development and testing.

1. Starting with an Empty Cart
  • Description: When a new ShoppingCart is created in Scala, it should start without any items, and the total price should be zero.
  • Details
    • Initialize a new shopping cart using the ShoppingCart constructor (e.g., val cart = new ShoppingCart()).
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal