init geek calc
Some checks failed
Deploy to GitHub Pages / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-04 10:53:41 +08:00
commit 54f427ea21
45 changed files with 4878 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
# Data Model: Geek Calculator
## Entities
### Calculation Expression
- **Representation**: String containing numbers, operators (+, -, ×, ÷), parentheses, percentage, +/- signs
- **Validation**: Must follow valid mathematical expression syntax rules
- **State transitions**: In-progress expression → evaluated expression → stored in history
### Calculation Result
- **Representation**: Number (JavaScript number type, may be Infinity or finite value)
- **Validation**: Must be a numeric result from evaluation
- **State transitions**: Calculated from expression → displayed → stored in history
### RPN Stack
- **Representation**: Array of numbers representing operands in Reverse Polish Notation
- **Operations**: Push, pop, peek, clear, size
- **Validation**: Elements must be valid numbers
- **State transitions**: Empty → populated with operands → modified through RPN operations
### Calculation History Entry
- **Fields**:
- expression (string): The original input expression
- result (number): The calculated result
- timestamp (Date): When the calculation was completed
- id (string): Unique identifier for recall
- **Validation**: Expression and result must be valid
- **State transitions**: New entry → stored → accessed → potentially deleted when limit reached
### Application Settings
- **Fields**:
- theme (string): 'dark' or other theme options
- mode (string): 'standard' or 'rpn' for calculation mode
- historyLimit (number): Maximum number of history entries to store
- **Validation**: Values must be from predefined sets
- **State transitions**: Default settings → user modified → saved to localStorage
### User Input State
- **Fields**:
- currentValue (string): The current value being entered
- operator (string): The current operator in use
- previousValue (number): The previous operand
- calculationPending (boolean): Whether a calculation is ready to execute
- **Validation**: Values must be consistent with calculator state
- **State transitions**: Initial state → value entry → operator selection → result calculation