How madhvesh77/cricket-score-calculator works
Project type and purpose
• Type: Command Line Interface (CLI) simulation program in C.
• Purpose: Interactive ball-by-ball cricket match simulator that prompts the user for each delivery’s event and updates a running scorecard.
File structure
• Top level:
– “Cricket scorecard.c”: a single-file C program implementing all logic
– “README.md”: project description
– “Output Screenshots.docx”: sample outputs
• No separate folders or modules; everything lives in one source file.
README for insights
• Core functionality:
– User input per ball
– State update (runs, wickets, strike rates, economy)
– Real-time display of the scorecard
• Data tracked: batsmen, bowlers, team totals, statuses.
Main components (to include
a. User Interface (CLI)
– Input Handler: reads event strings (“dot ball”, “four”, “wicket”, etc.)
– Output Renderer: prints the updated scorecard
b. Simulation Engine (Controller)
– Event Processor: maps input to state changes
– Rule Engine: applies cricket scoring rules
c. Data Model (State)
– Player Records: batsman and bowler stats
– Match State: total runs, overs, wickets, current striker/non-striker
d. Storage (in-memory)
– Arrays or structs holding player and team data
e. Main Function (Orchestrator)
– Bootstraps the loop: read input → process → render → repeat
Relationships and interactions
• User → Input Handler: “Enter event”
• Input Handler → Event Processor: raw event code
• Event Processor → Data Model: update player/match state
• Data Model ←→ Rule Engine: fetch and apply scoring logic
• Data Model → Output Renderer: generate formatted scorecard
• Output Renderer → User: print updated scoreboard
Architectural patterns and principles
• Model-View-Controller (MVC-like):
– Model = Data Model (structs)
– Controller = Simulation Engine (event processing + rules)
– View = CLI Output Renderer
• Single responsibility per module for clarity.
• Loop-driven event loop: ensures real-time feedback.
Technologies and libraries
• Language: C (standard library)
• No external dependencies—pure console I/O (scanf/printf).