Need help...

Hi guys so I got this assignment and it is due tomorrow. I have been trying to get out of the mud and start working on it however I'm really trapped in a lot of areas.... I hope someone can help me... Here is the description and I will put my so far code dowm below.. the code sucks and I dont know what to do.. Please help...

You’ll read in data from three different text files:
Team member names for team A, a Team Member Input File
Team member names for team B, a Team Member Input File
Laser Tag Match file giving information about what player successfully tagged another, a Match File
Your program will aggregate the data from the Match File to be used for output. Let’s take a look at each input file type.
Team Member input file
The first line of this file will contain the team name. The name of the team may contain spaces.
The second line of this file will contain a positive integer 1 < n <= 10 representing the number of members on the team.
The next n lines will contain team member’s id number (a positive integer), a single space, and the team member’s name. Names may contain spaces.
The name of the file will be provided via a command-line argument when the program is executed. As to be expected, each execution of the program will require two different Team Member input files.
Match File
The first line of the file will contain a positive integer 1 < n <= 100000 representing the number of ‘tags’ that happened during a particular match
The next n lines will contain 4 fields each separated by a single space:
Field 1: Tagger’s ID number, a positive integer
Field 2: Target’s ID number, a positive integer
Field 3: Number of milliseconds since the match started, a positive integer
Field 4: Location ID where target was hit (chest, back, shoulder, etc), a positive integer
For each execution of the program, only one Match File will be used.
Tag Scoring
The score received for a tag depends on the location the target was tagged. Locations have the following ID’s and point values:
1 (Back): 5 points
2 (Chest): 8 points
3 (Shoulder): 10 points
4 (Laser gun): 15 points
Output File
All results should be written to an output file.



Command-Line Parameters
The input data files and verbosity level will be passed to the program as command-line parameters.
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
#include <iostream>
#include <fstream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
    if(argc <= 6)
    {
        cour<< "Incorrect number of arguments"<< endl;
        return 1;
    }
    
    ifstream inputFile (argv[1]);
    if(!inputFile.is_open())
    {
        cout<< "COuld not open the input file\n";
        return 1;
    }
    else if(!outputFIle.is_open())
    {
        cout<< "Couldn not open the output file\n"<<endl;
        return 1;
    }
    
    vector<int> 
}

void vlow()
{
    Input.myFile;
    myFile.open()
    ofstream outputFile (argv [2]);
}

void vmed()
{
    
}

void vhigh()
{
    
}
so what I dont understand is those things. And someone has given me some vague solutions but I really tried.. And still I cant figure this out..

1. How do I read in the form like "1 Bob" from my txt file and then store them separately like "1" in an integer vector and "Bob" in a string vector so that i can call them whenever I want.

2. How to write a method to call out the elements in the vectors as described so that they will "tag" each other. I know it should be a method. But seriously I have no clue about what to do...(and I know it should be random some random generator, but still...)

3. How will you output the results and also calculate all the outcomes when the tag is done.

I basically stuck at the "tag" period. But also yeah... I dont know too much about this..

Please some give me a detailed guide so that I may be able to deal with it before it's due... I thank you in advance...
Last edited on
Well. so far I got the code like this.
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
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
   int team1_Num;
   std::string team1_name;
   ifstream team1 (argv[1]);
   std::getline(team1,team1_name);//read in the variables in the txt file and save them .
   std::getline(team1,team1_Num);
   string* names_1 = new string[team1_Num];
   int* id_1 = new int [team1_Num];
   for(int i = 0; i < team1_Num; i++)
   {
       std::getline(team1,names_1[i], " ");
       std::getline(team1,id_1[i]);
   }

   int team2_Num;
   std::string team2_name;
   ifstream team2 (argv[2]);
   std::getline(team2,team2_name);//read in the variables in the txt file and save them .
   std::getline(team2,team2_Num);
   string* names_2 = new string[team2_Num];
   int* id_2 = new int [team2_Num];
   for(int i = 0; i < team2_Num; i++)
   {
       std::getline(team2,names_2[i], " ");
       std::getline(team2,id_2[i]);
   }

}


It's some progress I think.. BUT... Yeah still need a lot of guidance..
Last edited on
there is another thread about this assignment...

Number one issues with students is that you wont think of creating struct and class first , so basically no ... structure in your code .

At least create methods with useful tasks.

Also the code does not tell what is Team1 and Team2 , I dont see names like chest , soulder , laserGun . You might lose points for that . At least comments.

You need to think always that someone that does not know your assignment will understand your code simply by reading it .

Note also that avoiding methods leads generally to redundant code.

This is just a no-mean advise from me , that could help you . :)
Topic archived. No new replies allowed.