Advertisement
ivodevweb

Untitled

Dec 22nd, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | Software | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. #include <string>
  5. #include <vector>
  6.  
  7. class Jogador {
  8.     public:
  9.         Jogador(int number
  10.                 , std::string name
  11.                 , std::string position) : m_number{number}
  12.                                         , m_name{name}
  13.                                         , m_position{position} {}
  14.         void Print() {
  15.             std::cout << m_number << "," << m_name << "," << m_position << std::endl;
  16.         }
  17.  
  18.         int getNumber() const;
  19.         std::string getName() const;
  20.         std::string getPostition() const;
  21.  
  22.     protected:
  23.         int m_number = -1;
  24.         int op{-1};
  25.         std::string m_name;
  26.         std::string m_position;
  27. };
  28.  
  29.  
  30.  
  31. int main(int argc, char **argv) {
  32.     int op = -1;
  33.     Jogador j(int number
  34.                 , std::string name
  35.                 , std::string position);
  36.     while(true){    
  37.         std::cout << " (1)prencher vector - (2)Motrar dados do vector" << std::endl;
  38.         std::cin >> op;
  39.            if(op !=2){
  40.             std::ifstream in;
  41.             std::ofstream out;
  42.  
  43.             std::string line;
  44.  
  45.             std::vector<Jogador> jogadores;
  46.  
  47.             out.open("output.txt", std::ios_base::app);
  48.             in.open("FutTeamA.txt");
  49.  
  50.             while(!in.eof()) {
  51.                 int number = -1;
  52.                 std::string name;
  53.                 std::string position;
  54.  
  55.                 in >> number >> name >> position;
  56.  
  57.                 out << number << " " << name << " " << position << std::endl;
  58.  
  59.                 jogadores.emplace_back(number, name, position);
  60.             }
  61.            break;
  62.        }
  63.        std::cout << "Mostrando dados do vector.............." << std::endl;
  64.        
  65.          // j.Print(number,name,position);
  66.           j.Print();
  67.     }
  68.    
  69.    
  70.  
  71.     return EXIT_SUCCESS;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement