Confused all the way..Really need help..

HI guys,
My lab has come out and I'm really lost About this assignment... Idont know how to do commandline arguments.. I dont know how to use vectors to deal with the numbers and ...can some kind sir take alook and give me some ideas and instructions? Really appreciate any help...

Here is the instruction

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
Your Task
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.  Your program should have three different verbosity levels of output:
Low verbosity (vlow):  Output the cumulative score of each team on a separate line and on line 3, output the winning team.  If there is a tie, state such instead of a winning team.
Medium Verbosity (vmed):  For both teams, output the team name and then each team members name followed by the number of successful tags they achieved (i.e., how many total times they successfully tagged another player).  Then output the highest-ranking member for each team followed by the winning team.
High Verbosity (vhigh):  Print the team name.  Then, for each player on a team, list each player on the opposing team that they tagged and the number of tags achieved against that player.  This should be followed by the total number of tags for that player.  After all of the players for one team have been output, print the total score for that team.  After player detail for both teams have been output, output the winning team.

Command-Line Parameters
The input data files and verbosity level will be passed to the program as command-line parameters. The parameters will have the following order, where verbosity is one of vlow, vmed, or vhigh mentioned above:
./a.out TeamA.txt TeamB.txt MatchFile.txt OutputFile.txt verbosity
  Put the code you need help with here.
Last edited on
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.


Idont know how to do commandline arguments

Is it really so that an assignment requires a feature that has not been described on the class?
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
#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()
{
    
}

attemot so far... dont even know how to read in file when I dont have the name for it since I was required to make commandline argument so I dont make the name myself thus Im totally trapped.. Somebody Help!!!!!!
Last edited on
Break your problem into parts and work on each one at a time.
Task1 is to use something like notepad to create two test files named.
"TeamA.txt" and "TeamB.txt"
Then find out how to load them into the computer and display them.
You can then process that stored data into the form to be ouput.
Output to the console so you can see if it works and then write the code to output to a file.
Last edited on
Thank you this method is actually working.. Can I ask you some questions later if I came into a gridlock?
Well if you get gridlock there are others who might help.
Have you written your test files?
With the "match.txt" file you can generate that from the "TeamA.txt" and "TeamB.txt" files by random selections,
eg.
"teamA.txt"
teamA
8
11 nameA1 A1
12 nameA2 A2
13 nameA3 A3
14 nameA4 A4
15 nameA5 A5
16 nameA6 A6
17 nameA7 A7
18 nameA8 A8

"teamB.txt"
teamB
8
21 nameB1 B1
22 nameB2 B2
23 nameB3 B3
24 nameB4 B4
25 nameB5 B5
26 nameB6 B6
27 nameB7 B7
28 nameB8 B8

"match.txt"
500
taggerID targetID time location
13 25 75 3
23 18 96 4
26 11 66 1
11 24 82 4
23 13 47 2
28 13 17 3
13 24 27 4
13 26 76 2
16 28 41 3
26 15 93 4
28 17 27 4
15 24 1 4
15 23 79 4
26 12 74 2
28 11 41 2
27 12 69 1
13 25 6 2
11 27 96 1
22 15 94 3
27 18 43 4
and so on up to 500 or whatever number you have chosen ...
Last edited on
so when read in the txt file. there is a certain form like 1 Bob. how do I manage to do that?
Your thread has a green tick so I assume it is done?
Your last question seems to flag that the problem is too advanced and you need to start with the basics of file i/o. Do you have a c++ teach yourself book?
If you have a text file like this:

teamB
7
Jefferson 17
Bill 24
Mary 29
Jack 22
Matthew 19
Claudia 23
Judy 18

You might read it like this.
Instead of printing it you would of course place the data into lists.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream fin("c:/codeBlockCode/teamB.txt");
    string teamName;
    string name;
    int id;
    int count;  // number of names

    fin >> teamName;
    cout << teamName << endl;
    fin >> count;
    cout << count << endl;
    while (fin >> name >> id)
    {
        // do something with data
        cout << name << " " << id << endl;
    }
}


Last edited on
Topic archived. No new replies allowed.