Cricket scoring is complex and I want to build an app in part to practice good design principles/patterns and develop a clean solution.
A few high level classes I have in mind are:
Match | Innings | Player | BallScore | TotalScore
There are states, some noticeable are following:
- CurrentInnings
- CurrentBatter
- NonStrikerBatter
Strategy
I am inclined for Match
to contain two Innings
and each innings are 11 Players
but then how to keep track of current innings and current batter/non-striker in clean way?
Or should the app simply work with current batter/non-striker-batter and bowler add them to match object once a batter is out? I would like the app to show current view of innings as show in picture
Any ideas welcome.
The main thing I am looking for is clean solution for keeping track of current innings and current batter (switching batter with scoring) and how to progress the match to 2nd innings.