Game App Algorithm
Game App Algorithm
#include <cstdlib>
#include <ctime>
class Team {
public:
string name;
name = teamName;
players[0] = p1;
players[1] = p2;
players[2] = p3;
totalRuns = 0;
};
string currentBatsman;
string currentBowler;
void greetUser() {
cout << "\nWelcome to the Gully Cricket App!" << endl;
cout << "Players: " << team.players[0] << ", " << team.players[1] << ", " << team.players[2] << endl;
currentBatsman = battingTeam.players[batsmanIndex];
currentBowler = bowlingTeam.players[bowlerIndex];
cout << "\nBatsman: " << currentBatsman << " | Bowler: " << currentBowler << endl;
int bowlDelivery() {
int runs = 0;
int balls = 6; // Each inning consists of 6 balls (one over)
cout << "Ball " << (i + 1) << ": " << score << " runs" << endl;
runs += score;
usleep(500000); // Wait for 0.5 second between balls for better user experience
return runs;
// Function to display the runs scored by the batting team at the end of the inning
cout << teamName << " scored " << runs << " runs in this inning." << endl;
cout << teamA.name << " scored " << teamA.totalRuns << " runs." << endl;
cout << teamB.name << " scored " << teamB.totalRuns << " runs." << endl;
} else {
int main() {
greetUser();
displayTeamDetails(TeamA);
displayTeamDetails(TeamB);
cout << "\nInning 1: " << TeamA.name << " bats" << endl;
selectBatsmanAndBowler(TeamA, TeamB);
displayInningRuns(TeamA.totalRuns, TeamA.name);
cout << "\nInning 2: " << TeamB.name << " bats" << endl;
selectBatsmanAndBowler(TeamB, TeamA);
displayInningRuns(TeamB.totalRuns, TeamB.name);
// Decide the winner
decideWinner(TeamA, TeamB);
return 0;