Q2
Q2
//#include <string>
//using namespace std;
//
//class Player
//{
//public:
// Player(string name, int score, int balls_played, int matches_played);
//
// virtual double calculateAverage() = 0;
// virtual void display() = 0;
//
// string name;
// int score;
// int balls_played;
// int matches_played;
//};
//
//class Batsman : public Player {
//public:
// Batsman( string name, int score, int balls_played, int matches_played,
// string batting_style, int total_score, int no_of_times_bowled);
//
// double calculateAverage() override;
// void display() override;
//
// string batting_style;
// int total_score;
// int no_of_times_bowled;
//};
//
//class Bowler : public Player {
//public:
// Bowler( string name, int score, int balls_played, int matches_played,
// string bowling_style, int total_wickets, int total_runs_conceded);
//
// double calculateAverage() override;
// void display() override;
//
// string bowling_style;
// int total_wickets;
// int total_runs_conceded;
//};
//
//#include <iostream>
//
//Player::Player(string name, int score, int balls_played, int matches_played)
// : name(name), score(score), balls_played(balls_played),
matches_played(matches_played) {}
//
//Batsman::Batsman( string name, int score, int balls_played, int matches_played,
// string batting_style, int total_score, int no_of_times_bowled)
// : Player(name, score, balls_played, matches_played),
// batting_style(batting_style),
// total_score(total_score),
// no_of_times_bowled(no_of_times_bowled) {}
//
//double Batsman::calculateAverage() {
// return static_cast<double>(total_score) / no_of_times_bowled;
//}
//
//void Batsman::display() {
// cout << "Batsman: " << endl;
// cout << "Name: " << name << endl;
// cout << "Score: " << score << endl;
// cout << "Balls played: " << balls_played << endl;
// cout << "Matches played: " << matches_played << endl;
// cout << "Batting style: " << batting_style << endl;
// cout << "Total score: " << total_score << endl;
// cout << "No. of times bowled: " << no_of_times_bowled << endl;
// cout << "Batting average: " << calculateAverage() << endl;
//}
//
//
//int main()
//{
// Batsman b1("ali", 23, 160, 5, "righthand", 180, 2);
// b1.display();
// cout << b1.calculateAverage();
//
// Bowler b2("Sam", 10, 170, 7, "fAST", 10, 10);
// //b2.display();
// //cout << b2.calculateAverage();
//
//
// system("pause>0");
//
//}