diff --git a/.cursor/plans/scientific-calculator-3075674a.plan.md b/.cursor/plans/scientific-calculator-3075674a.plan.md new file mode 100644 index 0000000..7546a88 --- /dev/null +++ b/.cursor/plans/scientific-calculator-3075674a.plan.md @@ -0,0 +1,90 @@ + +# Scientific Calculator Implementation Plan + +## Overview + +Extend the existing calculator architecture in `Models/` to add scientific computing capabilities, following the project's C# coding standards with `m_` prefix for private fields, `#region` blocks, and XML documentation. + +## Implementation Steps + +### 1. Create Scientific Calculator Interface + +**File**: `Models/IScientificCalculator.cs` + +- Extend `ICalculator` interface +- Add methods for scientific operations: +- Trigonometric: `Sin()`, `Cos()`, `Tan()`, `Asin()`, `Acos()`, `Atan()` +- Logarithmic: `Log()`, `Log10()`, `Ln()` +- Power/Root: `Power()`, `SquareRoot()`, `CubeRoot()`, `NthRoot()` +- Other: `Factorial()`, `Absolute()`, `Modulus()` +- Constants: Properties for `Pi`, `E` + +### 2. Implement Scientific Calculator + +**File**: `Models/ScientificCalculator.cs` + +- Inherit from `Calculator` class +- Implement `IScientificCalculator` interface +- Use proper `#region` blocks (Private Fields, Constructors, Public Methods, Private Methods) +- Add angle mode support (Degrees/Radians) with private field `m_angleMode` +- Implement all scientific operations using `System.Math` +- Include proper error handling (negative factorial, domain errors for trig) +- Record operations in history (inherited from base) +- Add XML documentation for all public methods + +### 3. Create Console Application + +**File**: `Demo/ScientificCalculatorApp.cs` + +- Create console UI with menu system +- Display available operations grouped by category (Basic, Trigonometric, Logarithmic, Power/Root, Other) +- Input validation for numbers and operation selection +- Support for angle mode toggle (Degrees/Radians) +- Display memory and history features +- Exit option +- Use proper `#region` blocks and follow naming conventions + +### 4. Create Comprehensive Unit Tests + +**File**: `Tests/ScientificCalculatorTests.cs` + +- Follow test naming: `MethodName_StateUnderTest_ExpectedBehavior` +- Use Arrange-Act-Assert pattern +- Test categories: +- **Basic Operations**: Verify inherited Add/Subtract/Multiply/Divide still work +- **Trigonometric Tests**: Test Sin/Cos/Tan in both degrees and radians, edge cases (0, 90, 180, 360 degrees) +- **Inverse Trigonometric Tests**: Test Asin/Acos/Atan with valid ranges +- **Logarithmic Tests**: Test Log/Log10/Ln with positive numbers, verify domain errors for negative/zero +- **Power/Root Tests**: Test Power, SquareRoot, CubeRoot, NthRoot with various inputs +- **Factorial Tests**: Test positive integers, zero, verify error for negatives +- **Angle Mode Tests**: Verify degree/radian conversions work correctly +- **Memory Tests**: Verify memory operations inherited from base +- **History Tests**: Verify scientific operations are recorded +- **Error Handling Tests**: Test all exception scenarios + +### 5. Update Existing Files (if needed) + +- Add namespace references if required +- No changes to existing `ICalculator` or `Calculator` to maintain backward compatibility + +## Key Design Decisions + +- **Inheritance**: `ScientificCalculator` extends `Calculator` to reuse memory and history functionality +- **Interface Hierarchy**: `IScientificCalculator` extends `ICalculator` for polymorphism +- **Angle Handling**: Default to Radians, provide mode toggle, convert internally when needed +- **Constants**: Expose `Math.PI` and `Math.E` as properties for convenience +- **Error Handling**: Use specific exceptions (`ArgumentException`, `ArgumentOutOfRangeException`) with clear messages + +## Files to Create + +1. `Models/IScientificCalculator.cs` - Interface definition +2. `Models/ScientificCalculator.cs` - Implementation (~200-250 lines) +3. `Demo/ScientificCalculatorApp.cs` - Console application +4. `Tests/ScientificCalculatorTests.cs` - Comprehensive unit tests (~500-600 lines) + +### To-dos + +- [ ] Create IScientificCalculator interface extending ICalculator with scientific operation methods +- [ ] Implement ScientificCalculator class with all scientific operations, angle mode support, and error handling +- [ ] Build console application with menu system for scientific calculator operations +- [ ] Create comprehensive unit tests covering all scientific operations, edge cases, and error handling \ No newline at end of file