0% found this document useful (0 votes)
10 views2 pages

File Handling

file handling

Uploaded by

aleesha waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

File Handling

file handling

Uploaded by

aleesha waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: Aleesha Waqar

Class :BEE-14 A

CMS ID: 417349

Lab :file handling and error handling

Code :

#ifndef TEAM_H

#define TEAM_H

#include <iostream>

#include <string>

#include <vector>

#include <fstream>

class Player {

public:

std::string name;

int matchesPlayed;

int runsScored;

int wicketsTaken;

int strike;

int halfCenturies;

int centuries;

int ballsPlayed;

double strikeRate;

int runsTaken;

};

class Team {

public:
std::vector<Player> players;

void addPlayer(const Player& player);

void replacePlayer(int index, const Player& player);

void swapPlayerOrder(int index1, int index2);

void printData() const;

void readData(const std::string& filename);

void writeData(const std::string& filename);

Player findBestBatsman() const;

Player findBestBowler() const;

void writeBestBatsman(const std::string& filename) const;

void writeBestBowler(const std::string& filename) const;

};

#endif

#include "team.h"

int main() {

Team myTeam;

// Reading data

myTeam.readData("players\\India.csv");

myTeam.printData();

myTeam.writeBestBatsman("best-batsman.csv");

myTeam.writeBestBowler("best-bowler.csv");

return 0;

You might also like