This is part of mine program but why the random number cant follow the file processing number?
this is mine card.txt
1 Abyss Devolos F0647 Balance NA SpeedStorm
2 Ace Dragon E7609 Attack NA HyperSphere
3 Anubion A2 E1057 Defense NA Dual-Layer
4 Balar B4 E4726 Attack NA SlingShock
5 Crystal Dranzer F0217 Balance NA Burst
6 Cyclone Belfyre F3965 Stamina Attack QuadDrive
7 Dark-X Nepstrius E4749 Defense NA SlingShock
8 Diomedes D2 E1062 Attack NA Dual-Layer
9 Doomscizor E1033 Attack NA SwitchStrike
10 Vatryek Wing Accel B9492 Attack NA Burst
What I have tried:
#include <iostream>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
const string cardfile=("cards.txt");
void readData(string,int);
int RandomCardP1 (int);
int RandomCardP2 (int);
int CheckSystem (int , int , int , int );
void ShowCardP1(int , string [], string [], string [], string[] , string []);
void ShowCardP2(int, string [], string [], string [], string [], string []);
int FinalScore();
int main(){
srand(time(0));
string nameP1,nameP2;
char respond='Y';
int scP1=0,scP2=0;
const int SIZE=10;
int ID [SIZE]={1,2,3,4,5,6,7,8,9,10};
string beybladeName[SIZE]={"Abyss Devolos","Ace Dragon","Anubion A2","Balar B4","Crystal Dranzer","Cyclone Belfyre","Dark-X Nepstrius","Diomedes D2","Doomscizor","Vatryek Wing Accel"};
string pCode[SIZE]={"F0647", "E7609", "E1057", "E4726", "F0217", "F3965", "E4749", "E1062", "E1033", "B9492 "};
string type[SIZE]={"Balance", "Attack", "Defense", "Attack", "Balance", "Stamina", "Defense", "Attack", "Attack", "Attack"};
string plusMode [SIZE]={"NA", "NA", "NA", "NA", "NA", "Attack", "NA", "NA", "NA", "NA"};
string system [SIZE]={"SpeedStorm", "HyperSphere", "Dual-Layer", "SlingShock", "Burst", "QuadDrive", "SlingShock", "Dual-Layer", "SwitchStrike", "Burst" };
void readData(string Data){
string line;
ifstream infile;
infile.open("cards.txt");
if (!infile.is_open())
cout << "Failure to open the file";
while (getline(infile, line))
{
cout << line << '\n';
}
infile.close();
}
int RandomCardP1 (int Ran)
{
unsigned int IDcardP1 = 0;
IDcardP1 = rand()%9 + 1;
return IDcardP1;
}
int RandomCardP2 (int Ran)
{
unsigned int IDcardP2= 0;
IDcardP2 = rand()%9 + 1;
return IDcardP2;
}
int CheckSystem (int systemP1, int systemP2, int scP1, int scP2)
{
if (systemP1>systemP2)
{
cout << "Player 1" <<endl;
scP1+=10;
}
else
{
cout << "Player 2" <<endl;
scP2+=10;
}
return scP1,scP2;
}
void ShowCardP1(int IDcardP1, string beybladeName[], string pCode[], string type[], string plusMode[], string system[]) {
cout<< "Product code: " << pCode[IDcardP1] << " " << endl;
cout<< beybladeName[IDcardP1] << " " << endl ;
cout<< "Type: " << type[IDcardP1] << " " << endl;
cout<< "PlusMode:" << plusMode[IDcardP1] << endl;
cout<< "System: " << system[IDcardP1] << endl;
}
void ShowCardP2(int IDcardP2, string beybladeName[], string pCode[], string type[], string plusMode[], string system[]) {
cout<< "Product code: " << pCode[IDcardP2] << " " << endl;
cout<< beybladeName[IDcardP2] << " " << endl ;
cout<< "Type: " << type[IDcardP2] << " " << endl;
cout<< "PlusMode:" << plusMode[IDcardP2] << endl;
cout<< "System: " << system[IDcardP2] << endl;
}