So I have a program with a specification file, implementation file, and a client file, I'll post all three but I know the problem rests in the client file. What's happening is that it reads the first team from my data file which I'll also post, and then it doesn't output the other two teams correctly. Anyway here's all the stuff:

// Implementation file for Team ADT.

#include <iostream>
#include "team.h"
#include <string>
using namespace std;

void TeamClass::Set(string teamname)
{
        teamName = teamname;
        wins = 0;
        losses = 0;
        GameCount = 0;
        totalteamscore = 0;
        totalotherscore = 0;
        return;
}


void TeamClass::AddGame(int teamscore, int otherscore)
{
        team = teamscore;
        other = otherscore;

        if (teamscore > otherscore)
        {
                wins = wins + 1;
                GameCount = GameCount + 1;
                totalteamscore = totalteamscore + teamscore;
                totalotherscore = totalotherscore + other;
        }
        else
        {
                losses = losses + 1;
                GameCount = GameCount + 1;
                totalteamscore = totalteamscore + teamscore;
                totalotherscore = totalotherscore + other;
        }
}

string TeamClass::GetName()
{
        cout << teamName <<endl;

}

int TeamClass::GetWins()
{
        cout << "Wins: " <<  wins <<endl;

}

int TeamClass::GetLosses()
{
        cout << "Losses: " << losses <<endl;

}

float TeamClass::GetWinPct()
{
        WinPct = wins/GameCount;
        cout <<"Pct: " <<  WinPct << endl;
}

int TeamClass::GetScoreDiff()
{
        ScoreDiff = totalteamscore - totalotherscore;
        cout << "Differential: " << ScoreDiff << endl;

}
// Specification file <team.h> for tracking teams.

#include <string>
using namespace std;

class TeamClass
{
public:
        void Set(string);
        void AddGame(int, int);
        string GetName();
        int GetWins();
        int GetLosses();
        float GetWinPct();
        int GetScoreDiff();

private:
        string teamName;
        int team;
        int other;
        int wins;
        int losses;
        float WinPct;
        int ScoreDiff;
        float GameCount;
        int totalteamscore;
        int totalotherscore;
};
#include "team.h"
#include <string>
#include <fstream>
using namespace std;

int main()
{
        TeamClass aTeam;
        string teamName;
        int team;
        int other;
        ifstream inFile;
        string filename;
        cout << "Input file?" << endl;
        cin >> filename;
        inFile.open(filename.c_str());
        getline(inFile, teamName);
        while (inFile)
        {
        aTeam.Set(teamName);
        inFile >> team >> other;
        while (team!=-1  && other != -1)
                {
                        aTeam.AddGame(team, other);
                        inFile >> team >> other;
                }
        aTeam.GetName();
        aTeam.GetWins();
        aTeam.GetLosses();
        aTeam.GetWinPct();
        aTeam.GetScoreDiff();

        }

        return 0;
}

And the text file reads as is:
St. John's Purple Dragons
2 0
0 1
4 1
-1 -1
General McLane Lancers
4 1
0 1
5 2
-1 -1
Raging Rhinos
3 2
1 0
-1 -1

I would appreciate any help on the matter, like I said I've pinpointed it to the Client File, but I can't figure out what's wrong with it.

I figured it out, after just goofing around with code for a few hours, it finally works, and I don't even understand how the code I've added really fixes it. Maybe someone can explain that to me instead, anyway here's the working code:

#include "team.h"
#include <string>
#include <fstream>
using namespace std;

int main()
{
        TeamClass aTeam;
        string teamName;
        int team;
        int other;
        ifstream inFile;
        string filename;
        cout << "Input file?" << endl;
        cin >> filename;
        inFile.open(filename.c_str());
        getline(inFile, teamName);
        while (inFile)
        {
        aTeam.Set(teamName);
        inFile >> team >> other;
        while (team!=-1  && other != -1)
                {
                        aTeam.AddGame(team, other);
                        inFile >> team >> other;

                }
        getline(inFile, teamName);
        aTeam.GetName();
        aTeam.GetWins();
        aTeam.GetLosses();
        aTeam.GetWinPct();
        aTeam.GetScoreDiff();
        aTeam.Set(teamName);
        getline(inFile, teamName);
        }

        return 0;
}

Did you just add some getlines? It's hard to see what you did differently. Could you maybe highlight it in your code?

Those are the three lines of code I added to the client file and now it reads in as many teams and scores as are typed into the text file it's reading from.

This question has already been answered. Start a new discussion instead.