I'm getting this
fatal error C1004: unexpected end-of-file found
error and I've checked all of my brackets. What else could be the problem?
Name:
Anonymous2009-10-05 16:37
#include <cstdlib>
#include <iostream>
#include <string>
// random stats should be 8-25
using namespace std;
int hall = 0;
string name;
int time;
int money;
int intelligence;
int Highscore[10];
bool win = false;
class main {
void menu() {
int selection = 0;
cout << "Enter the number for your selection:\n " << "1.Start Game\n" << "2.High Scores\n" << "3.Exit";
cin >> selection;
if (selection == 1) {
cout << "Please enter the character's name\n ";
cin >> name;
cout << "Welcome to your doom," + name;
character();
menu2();
} else if (selection == 2) {
int size = 10;
for (int i = 0; i < size; i++) {
cout << Highscore[i] << "\n";
}
} else if (selection == 3) {
exit(0);
} else {
cout << "Please enter a valid selection.";
cin >> selection;
}
}
int selection;
cout << name << "You have " << (20 - hall) << "steps to go.\n";
cout << "1. Move foward (sorry, you can't turn back now)\n";
cout << "2. View character\n";
cout << "3. Read technical papers\n";
cout << "4. Search for loose change\n";
cout << "5. Quit the game\n";
cout << "Enter your selection:";
cin >> selection;
int randtime = (rand() % 10);
int randmoney = (rand() % 10);
int randint = (rand() % 10);
if (selection == 1) {
Encounters();
} else if (selection == 2) {
cout << "Time = " << time << "\n" << "Money = " << money << "\n" << "Intelligence = " << intelligence << "\n";
menu2();
} else if (selection == 3) {
cout << " You lose " << randtime << " time\n" << " but gain " << randint << " intelligence.";
menu2();
} else if (selection == 4) {
cout << " You lose " << randtime << " time\n" << " but gain " << randmoney << " money.";
menu2();
} else if (selection == 5) {
exit(0);
} else {
cout << "Please enter a valid selection.";
cin >> selection;
}
}
void menu3() {
cout << "\a You have died\n" << " Your score only records if you win. Sorry.\n";
menu();
}
void menu4() {
Highscore[1] = time + money + intelligence;
cout << "\a You have won!\n" << "Time = " << time << "+\n" << "Money = " << money << "+\n" << "Intelligence = " << intelligence << "+\n";
cout << " Equals your score of..." << Highscore[1] << "\n" << "Check to see if your score made it in the top 10 list!\n";
menu();
}
void Encounters() {
int chance = (rand() % 20 + 1);
int randtime = (rand() % 10);
int randmoney = (rand() % 10);
int randint = (rand() % 10);
if (chance <= 1) {
//10%
cout << " You have to grade papers.\n" << " You lose " << randtime << " time\n" << " but gain " << randmoney << " money.";
hall++;
time = time - randtime;
money = money + randmoney;
menu2();
} else if (chance <= 6) {
//25%
cout << "Nothing happens." << "You lose 1 time.";
hall++;
time--;
menu2();
} else if (chance <= 11) {
//25%
cout << "You encounter a puzzle.";
puzzle();
} else if (chance <= 13) {
//10%
cout << " You encounter a professor!" << " You lose " << randtime << "time....\n" << " but gain " << randint << "intelligence!";
hall++;
time = time - randtime;
intelligence = intelligence + randint;
menu2();
} else if (chance <= 16) {
//15%
cout << " You are attacked by grunt work!" << " You lose " << randtime << " time and\n" << randint << " intelligence.";
hall++;
time = time - randtime;
intelligence = intelligence - randint;
menu2();
} else if (chance <= 18) {
//10%
cout << " You encounter a graduate student.\n" << " You lose " << randtime << " time.";
hall++;
time = time - randtime;
menu2();
} else if (chance >= 19) {
cout << "You found a nickel! Too bad it was glued to the floor..\n" << " Lose 1 time trying to pry the nickel off the floor.";
time--;
hall++;
menu2();
}
}
void puzzle() {
int answer;
int q = (rand() % 5);
if (q <= 1) {
cout << "How much time do you have left?";
cin >> answer;
if (answer != time) {
cout << "Apparently NONE!";
menu3();
} else {
cout << "You gain 1 time!";
time++;
hall++;
menu2();
}
}
if (q == 2) {
cout << "What level COMP class is this?";
cin >> answer;
if (answer != 2710) {
cout << "You must never come to class...";
menu3();
} else {
cout << "You gain 1 time!";
time++;
hall++;
menu2();
}
if (q == 3) {
cout << "What is 5 % 4?";
cin >> answer;
if (answer != 1) {
menu3();
} else {
cout << "You gain 1 time!";
time++;
hall++;
menu2();
}
if (q == 4) {
cout << "What is 4444 - 3107 ?";
cin >> answer;
if (answer != 1337) {
menu3();
} else {
cout << " You gain leet time! (actually just 1, sorry.)";
time++;
hall++;
menu2();
}
}
}
}
}
};
i fixed it up a little bit; but it is still tragic what you are doing. it will not function as you expect it to.