1
        #include <iostream>
        #include <fstream>
        #include <string> 

        using namespace std;

        class BasketballPlayer
        {
        public:
            void printBasketballPlayer() const;
            BasketballPlayer(); //Default Constructor
            BasketballPlayer(string); //Constructor with Parameters
                
        private:
            string name;
            int MinutesPlayed;
            float PlayerScoreEffRating;
            float Steals;
            float AST;
            float PointPerGame;
            float Rebounds;
            float FieldGoal;
            float FreeThrow;
            float ThreePointers;
            float BLK;
            float TurnOver;
            //More Data members
        };
        
        class BasketballTeam
        {
        public:
            void printBasketballTeam() const;
            bool findPlayer(const BasketballPlayer &) const;
            void editPlayer(BasketballPlayer &);
            int WinningTeam(const BasketballPlayer &);
            BasketballTeam(); //Default Constructor
         
            
        private:
            BasketballPlayer[18];
        }
        
        int main()
        {
          
            ofstream outdata;
            outdata.open("FlieNets.csv");
            return 0;
        }//end main
        
        void BasketballPlayer::printBasketballPlayer() const
        {
            BasketballPlayer Player;
            
         
            cout << "|| The players name || " << Player.name;
            cout << endl;
        
            cout << "|| Minutes Per Game || " <<Player.MinutesPlayed;
            cout << endl;
        
            cout << "|| Turnovers Per Game || " << Player.TurnOver;
            cout << endl;
        
            cout << "|| Points Per Game || " << Player.PointPerGame;
            cout << endl;
        
            cout << "|| Rebounds Per Game || " << Player.Rebounds;
            cout << endl;
        
            cout << "|| Asists Per Game || " << Player.AST;
            cout << endl;
        
            cout << "|| Blocks Per Game || " <<  Player.BLK;
            cout << endl;
        
            cout << "|| 3 Point % || " << Player.ThreePointers;
            cout << endl;
        
            cout << "|| Free-Throw % || " << Player.FreeThrow;
            cout << endl;
        
            cout << "|| Field Goal %|| " << Player.FieldGoal;
            cout << endl;
        
            cout << "|| Steals % || " <<  Player.Steals;
            cout << endl;
        
            cout << "|| Player Scoreing Effiencey Rating || " << Player.PlayerScoreEffRating;
            cout << endl;
    
        }
        BasketballPlayer::BasketballPlayer() //Default Constructor
        {
            name = "TBD";
            MinutesPlayed = 0;
            PlayerScoreEffRating = 0;
            Steals = 0;
            AST = 0;
            PointPerGame = 0;
            Rebounds = 0;
            FieldGoal = 0;
            FreeThrow = 0;
            ThreePointers = 0;
            BLK = 0;
            TurnOver = 0;

    
        }
        BasketballPlayer::BasketballPlayer(string) //Constructor with Parameters
        { 
            BasketballPlayer Player;
    
            Player.name = " James Harden";
            Player.MinutesPlayed = 40.2;
            Player.TurnOver = 4.2;
            Player.PointPerGame = 24.1;
            Player.Rebounds = 8.1;
            Player.AST = 12.0;
            Player.BLK = 0.6;
            Player.ThreePointers = 37.9;
            Player.FreeThrow = 89.2;
            Player.FieldGoal = 48.2;
            Player.Steals = 1.1;
            Player.PlayerScoreEffRating = 1.561;

        }

        void BasketballTeam::printBasketballTeam()
        {
            BasketballTeam Team;
  
            BasketballTeam();
    
            while (line != " ")
            {

            }
        }
        bool BasketballTeam::findPlayer(const BasketballPlayer&)
        {
            bool Finder = false;

            BasketballTeam Team;

            if (BasketballPlayer)
            {
                Finder = true;
            }

            return Finder;
        }
        void BasketballTeam::editPlayer(BasketballPlayer &)
        {

    
        }
        BasketballTeam::BasketballTeam() //Default Constructor
        {
            ofstream outdata;
            outdata.open("FlieNets.csv");
        }

So I have an excel sheet of the brooklyn nets stats I converted it in csv. Their are 17 players in the file with 11 stats each. It reads player name, Mintues played, etc. So I want to read from file and add the data into my basketballTeam class. Really green about classes and hate doing fsteam. I need to be able to search the data of player by their name then be able to change any of their stats.

FlieNets.csv

Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56
L0ST
  • 21
  • 2
  • You have to read each line of the file, split it at the separator (I assume it's `;`) and then set each of the player members to the value you read. `"hate doing fsteam"` I don't think you will get around using that. – perivesta Feb 05 '21 at 16:48
  • The separator is ',' so the class team I understand that my data will be read into the obj team. Can I still then place the player class inside my team obj so that I can have the player's name be the class type player then give value to player.steals = value from file. Would I basically have to walk the data to were it should be? If so then since I made data in excel and excel has row, col that would be better? – L0ST Feb 05 '21 at 17:33

0 Answers0