足球联赛计划的功能

时间:2017-03-17 16:50:48

标签: c++

#include "stdafx.h"
#include "FootballTeam.h"
using namespace std;

CFootballTeam league[10];
int numTeams = 0;

int ShowMenu(void);
void DoInitalize();
void DoDisplayLeague(void);
void DoEnterMatchResult(void);
void DoDeductPoints(void);
void DoBestDefence(void);
void DoRelegationZone(void);
void DoAddTeamToList(void);
void DoQuit(void);

bool quitFlag = false;
int main()
{
    int option;
    do
    {
        option = ShowMenu();
        switch (option)
        {
        case 0:
            DoInitalize();
            break;
        case 1:
            DoDisplayLeague();
            break;
        case 2:
            DoEnterMatchResult();
            break;
        case 3:
            DoDeductPoints();
            break;
        case 4:
            DoBestDefence();
            break;
        case 5:
            DoRelegationZone();
            break;
        case 6:
            DoAddTeamToList();
            break;
        case 7:
            DoQuit();
            break;
        default:
            cout << "invalid option\n";
        }
    } while (!quitFlag);

    if (numTeams == 0)
        return 0;

    ofstream outfile("leagueInfo.dat");
    outfile << numTeams << endl;

    for (int i = 0; i < numTeams; i++)
    {
        outfile << league[i].GetName() << "  "
            /*<< league[i].GetGamesPlayed() << "  "
            << league[i].GetGoalsFor() << "  "
            << league[i].GetGoalsAgainst << "  "
            << league[i].GetPoints*/ << endl;
    }

    outfile.close();
    return 0;


    return 0;
}
int ShowMenu(void)
{
    int option;
    cout << "\t0.       Initialize League Table\n";
    cout << "\t1.       Display League Table\n";
    cout << "\t2.       Enter a Match Result\n";
    cout << "\t3.       Deduct Points\n";
    cout << "\t4.       Best Defence\n";
    cout << "\t5.       Relegation Zone\n";
    cout << "\t6.       Add Team to List\n";
    cout << "t7.        Quit\n";
    cout << "\t\t\t     Enter Option ? ";
    cin >> option;
    return option;
}


void DoInitalize()
{
    char response;
    do
    {
        string name;
        cout << "Enter a name:";
        cin >> name;
        CFootballTeam s(name);
        league[numTeams] = s;
        numTeams++;
        cout << "More (Y/N) ? ";
        cin >> response;
    } while (response == 'y' || response == 'Y');
}

这个id我到目前为止所拥有的代码对我来说似乎不对,这就是它的意思,我不认为这样做是正确的...任何帮助都应该被赞赏

DoInitialize应该初始化一个联赛表 选项0的回调//扫描集合.... 允许用户输入团队名称 实例化一个对象 将对象复制到集合中 有人可以帮我这个吗??

0 个答案:

没有答案