Skip to content

Instantly share code, notes, and snippets.

@stevebrownlee
Created August 7, 2025 14:09
Show Gist options
  • Save stevebrownlee/f181696fb42bec48dae9dfbce502a197 to your computer and use it in GitHub Desktop.
Save stevebrownlee/f181696fb42bec48dae9dfbce502a197 to your computer and use it in GitHub Desktop.
C# inheritance workshop requirements

C# Candy Shop Workshop - Requirements Document

Project Overview

Build a console application for a candy shop that demonstrates object-oriented programming concepts through inheritance and composition patterns.

Business Requirements

Candy Inventory System

  • The shop sells different types of candy: chocolates, gummies, and hard candies
  • Each candy has basic information: name, price, and sweetness level
  • Each candy type has unique characteristics that need to be tracked
  • The system must display candy information in a user-friendly format

Shop Organization System

  • Display Cases: Used to organize inventory by candy type
  • Each display case contains only one kind of candy (all chocolates, all gummies, etc.)
  • Display cases show what type of candy they contain and how many items are in stock
  • Staff should be able to add candy to the appropriate display case

Customer Purchase System

  • Party Baskets: Used for customer orders and gift combinations
  • Party baskets can contain any mix of candy types
  • Customers should be able to add any candy to their basket
  • The system should calculate total prices and show basket contents

Technical Learning Objectives

1. Inheritance Implementation

  • Create a base candy class with common properties and behaviors
  • Implement specialized candy types that extend the base class
  • Demonstrate code reuse and polymorphism through inheritance
  • Use virtual methods and method overriding appropriately

2. Composition Patterns

  • Flexible Composition: Implement containers that can hold multiple object types
  • Constrained Composition: Implement containers restricted to single object types
  • Compare and contrast when to use each approach
  • Demonstrate object relationships using "has-a" vs "is-a" concepts

3. Object-Oriented Design

  • Apply encapsulation principles with appropriate access modifiers
  • Design class relationships that model real-world scenarios
  • Create maintainable and extensible code structures
  • Demonstrate polymorphic behavior in collections

Success Criteria

For Inheritance:

  • All candy types share common functionality from base class
  • Each candy type displays its unique information correctly
  • Polymorphism works when treating different candies uniformly

For Composition:

  • Display cases enforce business rules (single candy type only)
  • Party baskets allow flexible combinations
  • Both container types manage their contents appropriately

For Application:

  • Console app demonstrates all classes working together
  • User can see the difference between organized inventory and mixed collections
  • Code is readable, well-structured, and demonstrates OOP principles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment