Structures & Data Storage¶
Stats¶
-
struct
Stats¶ Storage for all career statistics of an individual player.
These statistics are used to create predicitions and simulate parts of the game.
Public Members
-
int
innings¶ The number of innings in which the player has batted over their career.
-
double
bat_avg¶ Career batting average of the player (average runs per dismissal).
-
double
bat_sr¶ Career batting strike rate of the player (average runs per 100 balls faced).
-
int
balls_bowled¶ The number of balls bowled by the player over their career.
-
double
bowl_avg¶ Career bowling average of the player (average runs conceded per wicket).
-
double
bowl_sr¶ Career bowling strike rate of the player (average balls bowled per wicket).
-
double
bowl_econ¶ Career bowling economy of the player (average runs conceded per 6 balls bowled).
-
Arm
bat_arm¶ Batting hand of the player, as an enumeration with possible values right or left.
-
Arm
bowl_arm¶ Bowling arm of the player, as an enumeration with possible values right or left.
-
int
Player¶
-
class
Player¶ Storage for all detail describing a player.
Stores all information needed to describe a player, including name, team and statistics. Values are stored privately and accessed using getters, following typical OOP convention. Class also includes methods for formatting name (e.g. initials and last name, full name, etc.), and getters for each statistic stored in the Stats object.
Public Functions
-
Player(std::string c_first_name, std::string c_last_name, std::string c_initials, Stats stats)¶ Construct a new Player object.
- Parameters
c_first_name: First name of the player, e.g. Steven.c_last_name: Last name of the player, e.g. Smith.c_initials: Initials of the player to display on the scorecard, e.g. SPD.stats: Career statistics of the player.
-
MatchResult¶
-
class
MatchResult¶ Summarise the result of a match, including the winner and margin of victory if applicable.
There are five possible match results: a draw, . This class is immutable, as there would be no reason to modify the values after construction.
Public Functions
-
MatchResult(ResultType c_type, Team *c_winner = nullptr, unsigned int c_margin = 0)¶ Construct a new Match Result object.
- Parameters
c_type: The type of victory, as a ResultType enumeration.c_winner: Pointer to the winning team. This argument will be ignored if a winning team is not applicable.c_margin: Winning margin. This argument will be ignored if a winning team is not applicable.
-
std::string
print()¶ Format the result type, winner and margin of victory in a nice, printable string. For example, if India have won by 55 runs, the output would be “India won by 55 runs”.
- Return
- std::string The formatted string.
-