In soccer, 2-0 is often called by sports pundits to be the most dangerous lead, i.e. the lead most susceptible to comebacks. My research question is what is the effect that leads have (1-0, 2-0, 3-0, etc) on the opposing team's scoring ability. I am using the last 80 years of world cup data to analyze it. I would like to write a C++ program to help me primarily with data entry but also with data manipulation. This is difficult for me because I have only taken two computer science classes, and only one of them used C++. Let me try to explain how I am trying to use C++ and then I'll post my code.
For every game that I want to analyze there is only a few pieces of pertinent information that every other variable I want to analyze can be derived from. I am trying to enter in the data fro several hundred games, and later I would like to easily manipulate it. The way it works is this:
Each soccer game can be broken down into "events." An "event" is characterized by the current score, the start of the event (in minutes), and the end of the event (in minutes).
lets say Team A scores in the 20th minute. Therefore, the first event for this game starts at the 20th minute, with 1-0 being the score. Then lets say Team A scores again in the 46 th minute. Now there are two events in this game -- The first event, characterized by the 1-0 score, start time at minute 20 and end time at minute 46, and event 2nd event-- a score of 2-0, start time of 46 and end time of either the next event or until the game ends.
I am trying to break this down in C++ by using classes. the class structure is as follows:
World Cup -> Games -> Events -> (Score (I defined as a struct), Start time, End time, next event)
First, I would like to know if whether or not you think this is the most effect method to breakdown this problem (i.e. using classes).
Next, I would really love some help with this code. My C++ sucks. I'm still learning proper syntax as well as all the rules, even though I took a class on it. Below is my code.
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
|
#ifindef FIFAH
#define FIFAH
#include <stdlib.h>
#include <string>
#include <iomap>
#include <vector>
#include <iostream>
using namespace std;
class WC;
class Game;
class Event;
// "World Cup" (WC) has Games which are series of Events
typedef Game *gamep;
//pointer to the class game
typedef Event *eventp;
struct Score {
unsigned int a, b;
}; //gives the current score, is a variable in an Event
Class WC{
public:
vector<gamep> GameList; //list of pointers to games that have taken place in the WC
unsigned int GameNum; //Number of games in the WC
//constructor
WC { vector<gamep>, GameNum};
//member functions
void addGame(gamep); //adds a game to the Gamelist, intialized to zero upon construction, adds 1 to GameNum after each use
};
Class Game {
public:
WC *wc; //pointer to the WC with which the game is in
string TeamA; //the two teams playing in the game
string TeamB;
eventp ev; //and event in the game. namely, when someone scores
unsigned int EventNum; //number of events in the game
//constructor
Game(string, string, eventp, unsigned int EventNum);
};
Class Event {
public:
unsigned int STime; //start time of the event
unsigned int ETime; //end time of the event
eventp nxtEvent; // a pointer to the next event
//constructor
Event(Score, unsigned int, unsigned int, eventp);
};
|
I'm sure there are many problems in this where I have confused key concepts. One thing I am really unsure about is my recursive definition of an event (I don't remember ever covering this for classes specifically). Also, while I would love to compile this code, at the moment my access to the University's computers is suspended (Should get it back next week). I need this access so that I may compile remotely using their Linux servers. I tried downloading a compiler for windows (Dev-C++) but when I try to compile this header file, nothing happens.
Anyways, all help would be greatly appreciated.