1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
//main.cpp
#include <iostream>
#include <iomanip>
#include <ctime>
#include <fstream>
#include "title.h"
#include "startscreen.h"
using namespace std;
int main()
{
title(); //shows title screen
startscreen();
}
//startscreen.h
#pragma once
#include <iostream>
#include <conio.h>
#include "team.h"
#include "teameditP.h"
#include "teameditT.h"
using namespace std;
void startscreen()
{
while (1)
{
auto_team();
cout << "=*=*=*Welcome to FIFA World Cup 2018!=*=*=*\n\n\n";
cout << "\t1.Just Start with team without editing.\n\n";
cout << "\t2.Edit the team data for this run only.\n\n
cout << "\t3.Edit the team data peermanently." << endl << endl;
cout << "Press the option number!";
char option = getch();
if (option == '1') {
system("cls");
for (int i = 0; i < 4;i++) //temporarilly 4(or temporary printing)
printteam(Team[i]);
return;
}
//team.h
#pragma once
#include <iostream>
#include <fstream>
#include "player.h"
using namespace std;
class team
{
public:
friend void auto_team();
void getname(string nn)
{
team_name = nn;
}
void gethome(bool tf)
{
home = tf;
}
void getplayer(int k, int a, int b, string nn, int c, double d, int e, int f, bool g)
{
players[k].num = a;
players[k].position = b;
players[k].name = nn;
players[k].age = c;
players[k].condition = d;
players[k].contribution = e;
players[k].yellow = f;
players[k].avail = g;
}
void gettraining(double a)
{
training = a;
}
void getevent(double e)
{
event = e;
}
void getattack(int a)
{
attack = a;
}
void getdefense(int a)
{
defense = a;
}
void getstats(int a)
{
stats = a;
}
friend void printteam(team a);
void edit();
private:
string team_name;
bool home;
player players[19];
double training; //inital value 1.0
double event; //inital value 1.0
int attack;
int defense;
int stats; //reference fifa 2016 (mobile: cuz its free)
};
//team.cpp
#include <fstream>
#include <iostream>
#include <string>
#include "team.h"
using namespace std;
void auto_team()
{
team Team[4]; //temporarilly 4, change to 32
ifstream fin;
ofstream fout;
fin.open("DATA.txt");
int a, b, c, d, e;
string nn;
double dd;
bool f;
for (int i = 0; i < 4; i++) //change to 32
{
fin.getline >> nn;
Team[i].getname(nn);
fin >> f;
Team[i].gethome(f);
for (int i = 0; i < 19; i++)
{
fin >> a >> b;
fin.getline >> nn;
fin >> c >> dd >> d >> e >> f;
Team[i].getplayer(i, a, b, nn, c, dd, d, e, f);
}
fin >> dd;
Team[i].gettraining(dd);
fin >> dd;
Team[i].getevent(dd);
fin >> a;
Team[i].getattack(a);
fin >> a;
Team[i].getdefense(a);
fin >> a;
Team[i].getstats(a);
}
}
void printteam(team a)
{
cout << "Team Name: ";
cout << a.team_name << " ";
if (a.home)
{
cout << "(Hometeam)";
}
cout << endl;
cout << "************** Players **************" << endl;
for (int i = 0; i < 19; i++)
{
cout << a.players[i].num << ". " << a.players[i].name << " (";
cout << a.players[i].age << ")\t";
if (a.players[i].position == 0)
cout << "GK ";
else if (a.players[i].position == 1)
cout << "DF";
else if (a.players[i].position == 2)
cout << "MF";
else
cout << "FW";
cout << "\t";
cout << "G/A/S: " << a.players[i].contribution << endl;
}
cout << endl;
cout << "<Strategy>" << endl;
cout << "A:" << (a.attack * 10) << "%\tD: " << (a.defense * 10) << "%";
cout << endl;
cout << "Team Stats: " << a.stats << "/100";
}
//player.h
#pragma once
#include <iostream>
using namespace std;
struct player
{
int num;
int position; //0:GK 1:DF 2.MF 3:FW
string name;
int age;
double condition; //4
int contribution; //
int yellow;
bool avail;
};
|