Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <fstream>
- using namespace std;
- void display_names();
- void player_info();
- void info_choose();
- void info_edit();
- struct playerData
- {
- string name;
- string position;
- int TD;
- int C;
- int PaY;
- int ReY;
- int RuY;
- };
- playerData Player[10];
- int index;
- int edit;
- char response;
- int main()
- {
- ifstream text;
- text.open("Input.txt");
- for (index = 0; index < 10; index++)
- {
- text >> Player[index].name;
- text >> Player[index].position;
- text >> Player[index].TD;
- text >> Player[index].C;
- text >> Player[index].PaY;
- text >> Player[index].ReY;
- text >> Player[index].RuY;
- };
- while(response != 'q')
- {
- index = 0;
- display_names();
- cout << "\nSelect a player number to view info, then enter a number again or type q to quit.\n\n";
- cin >> index;
- cin >> response;
- index -= 1;
- if (response != 'q')
- {
- player_info();
- }
- };
- cout << "Have a nice day!";
- return 0;
- }
- void display_names() // Shows the names in order.
- {
- int index;
- for (index = 0; index < 10; index++)
- {
- cout << index+1 << ". " << Player[index].name << "\n";
- };
- }
- void player_info() // Shows player's information.
- {
- while (index < 10)
- {
- cout << "\n";
- cout << Player[index].name << "\n";
- cout << Player[index].position << "\n";
- cout << Player[index].TD << "\n";
- cout << Player[index].C << "\n";
- cout << Player[index].PaY << "\n";
- cout << Player[index].ReY << "\n";
- cout << Player[index].RuY << "\n";
- cout << "Would you like to edit the player's information? [y - n]]\n";
- cin >> response;
- if(response == 'y')
- {
- info_choose();
- }
- else
- {
- index = 10;
- response = ' ';
- };
- };
- }
- void info_choose()
- {
- cout << "Which would you like to edit?\n";
- cout << "1. " << Player[index].name << "\n";
- cout << "2. " << Player[index].position << "\n";
- cout << "3. " << Player[index].TD << "\n";
- cout << "4. " << Player[index].C << "\n";
- cout << "5. " << Player[index].PaY << "\n";
- cout << "6. " << Player[index].ReY << "\n";
- cout << "7. " << Player[index].RuY << "\n";
- cin >> edit;
- switch (edit)
- {
- case 1:
- cout << "Type in the new name.\n";
- cin >> Player[index].name;
- break;
- case 2:
- cout << "Type in new position.\n";
- cin >> Player[index].position;
- break;
- case 3:
- cout << "Type in the new number.\n";
- cin >> Player[index].TD;
- break;
- case 4:
- cout << "Type in the new number.\n";
- cin >> Player[index].C;
- break;
- case 5:
- cout << "Type in the new number.\n";
- cin >> Player[index].PaY;
- break;
- case 6:
- cout << "Type in the new number.\n";
- cin >> Player[index].ReY;
- break;
- case 7:
- cout << "Type in the new number.\n";
- cin >> Player[index].RuY;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement