Advertisement
ivodevweb

Untitled

Dec 22nd, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 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.  void Print() {
  30.             std::cout << m_number << "," << m_name << "," << m_position << std::endl;
  31.         }
  32.  
  33.  
  34. int Jogador::getNumber() const{
  35.     return m_number;
  36. }
  37. std::string::getName() const{
  38.     return m_name;
  39. }
  40. std::string::getPostition const{
  41.     return m_position;
  42. }
  43.  
  44. int main(int argc, char **argv) {
  45.     int op = -1;
  46.     Jogador j(int number
  47.                 , std::string name
  48.                 , std::string position);
  49.     while(true){    
  50.         std::cout << " (1)prencher vector - (2)Motrar dados do vector" << std::endl;
  51.         std::cin >> op;
  52.            if(op !=2){
  53.             std::ifstream in;
  54.             std::ofstream out;
  55.  
  56.             std::string line;
  57.  
  58.             std::vector<Jogador> jogadores;
  59.  
  60.             out.open("output.txt", std::ios_base::app);
  61.             in.open("FutTeamA.txt");
  62.  
  63.             while(!in.eof()) {
  64.                 int number = -1;
  65.                 std::string name;
  66.                 std::string position;
  67.  
  68.                 in >> number >> name >> position;
  69.  
  70.                 out << number << " " << name << " " << position << std::endl;
  71.  
  72.                 jogadores.emplace_back(number, name, position);
  73.             }
  74.            break;
  75.        }
  76.        std::cout << "Mostrando dados do vector.............." << std::endl;
  77.        
  78.          // j.Print(number,name,position);
  79.           j.Print();
  80.     }
  81.    
  82.    
  83.  
  84.     return EXIT_SUCCESS;
  85. }
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement