[Dev-C++] I dont see the error in my code, I need help with this.......
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Julio L. <ju2...@ya...> - 2001-07-21 22:42:04
|
This program has no other problems(ignoring the fact
that I am assigning rings to the dimensions of the
board) excpet that when I try to compile it, it says
parse error at end of input, and I dont see it.
#include <iostream.h>
#include <stdlib.h>
#include "Tower Ring Class.hpp"
//function prototypes
void gameBoard(char square[10][3]);
void playGame(char square[10][3]);
//This class creates te rings that will be placed on
the gameBoard
class Rings
{
Rings():
rings1[4]("777"),
rings2[6]("77777"),
rings3[8]("7777777"),
rings4[10]("777777777"),
rings5[12]("77777777777"),
rings6[14]("7777777777777"),
rings7[16]("777777777777777"),
rings8[18]("77777777777777777"),
rings9[20]("7777777777777777777"),
rings10[22]("777777777777777777777"),
rings11[4](" "),
rings12[6](" "),
rings13[8](" "),
rings14[10](" "),
rings15[12](" "),
rings16[14]{" "),
rings17[16](" "),
rings18[18](" "),
rings19[20](" "),
rings20[22](" ")
{
const char rings1[4];
const char rings2[6];
const char rings3[8];
const char rings4[10];
const char rings5[12];
const char rings6[14];
const char rings7[16];
const char rings8[18];
const char rings9[20];
const char rings10[22];
const char rings11[4];
const char rings12[6];
const char rings13[8];
const char rings14[10];
const char rings15[12];
const char rings16[14];
const char rings17[16];
const char rings18[18];
const char rings19[20];
const char rings20[22];
}
~Rings(){}
};
int main()
{
while(true)
{
// main menu
char square[10][3];
int choice;
cout << " THE TOWERS OF
HANOI\n\n";
cout << "
**********************************************************\n\n";
cout << " *MENU OF
CHOICES*\n\n";
cout << " (1)About THE TOWERS
OF HANOI\n\n";
cout << " (2)Object of THE
TOWERS OF HANOI\n\n";
cout << " (3)Rules of THE
TOWRERS OF HANOI\n\n";
cout << " (4)Play\n\n";
cout << " (5)Exit\n\n\n";
cout << " Please enter your
choice: ";
cin >> choice;
cout << "\n\n
**********************************************************\n\n";
switch(choice)
{
case 1: cout << " About
THE TOWERS OF HANOI\n\n";
cout << "The ancient puzzle of THE TOWERS OF
HANOI involves three pegs with numerous\n";
cout << "disks on the first peg. The disks
are arranged in decreasing order of size\n\n";
system("PAUSE");
continue;
case 2: cout << " Objective
of THE TOWERS OF HANOI\n\n";
cout << "The objective of this puzzle is to
move all the disks to the last peg.\n\n";
system("PAUSE");
continue;
case 3: cout << " Rules of
THE TOWERS OF HANOI\n\n";
cout << "The rules are that only one disk may
be moved at a time and that a larger\n";
cout << "disk may never be placed on a
smaller disk.\n\n";
system("PAUSE");
continue;
case 4: playGame(square);
break;
case 5: break;
default: break;
} //end switch
break;
}//end while(true)
return 0;
}//end main()
void playGame(char square[10][3])
{
//menu
int choiceRings;
cout << " THE TOWERS OF
HANOI\n";
cout <<
"***********************************************************************************\n\n\n";
cout << "\nHow many rings would you like there to be?
(min. 4, max. 10): ";
cin >> choiceRings;
cout << "\n\n";
//only choice for now
if(choiceRings == 4)
{
//gives each dimension on the board either an
empty space or a ring
Rings Aring;
const char localRings1, localRings2,
localRings3, localRings4;
const char localRings5, localRings6,
localRings7, localRings8;
const char localRings9, localRings10,
localRings11, localRings12;
const char localRings13, localRings14,
localRings15, localRings16;
const char localRings17, localRings18,
localRings19, localRings20;
localRings1= Aring.rings1;
localRings2= Aring.rings2;
localRings3= Aring.rings3;
localRings4= Aring.rings4;
localRings5= Aring.rings5;
localRings6= Aring.rings6;
localRings7= Aring.rings7;
localRings8= Aring.rings8;
localRings9= Aring.rings9;
localRings10= Aring.rings10;
localRings11= Aring.rings11;
localRings12= Aring.rings12;
localRings13= Aring.rings13;
localRings14= Aring.rings14;
localRings15= Aring.rings15;
localRings16= Aring.rings16;
localRings17= Aring.rings17;
localRings18= Aring.rings18;
localRings19= Aring.rings19;
localRings20= Aring.rings20;
square[0][0]= localRings11;
square[1][0]= localRings12;
square[2][0]= localRings13;
square[3][0]= localRings14;
square[4][0]= localRings15;
square[5][0]= localRings16;
square[6][0]= localRings7;
square[7][0]= localRings8;
square[8][0]= localRings9;
square[9][0]= localRings10;
square[0][1]= localRings11;
square[1][1]= localRings12;
square[2][1]= localRings13;
square[3][1]= localRings14;
square[4][1]= localRings15;
square[5][1]= localRings16;
square[6][1]= localRings17;
square[7][1]= localRings18;
square[8][1]= localRings19;
square[9][1]= localRings20;
square[0][2]= localRings11;
square[1][2]= localRings12;
square[2][2]= localRings13;
square[3][2]= localRings14;
square[4][2]= localRings15;
square[5][2]= localRings16;
square[6][2]= localRings17;
square[7][2]= localRings18;
square[8][2]= localRings19;
square[9][2]= localRings20;
// All of the following if's show each mve that has to
be made to win the game with four rings
cout << "This is what the game board looks when no
moves have been made, using four rings: \n";
gameBoard(square);
system("PAUSE");
cout << "After the first move to solving the game with
four rings is made, it looks like this: \n";
square[9][1]= localRings7;
square[6][0]= localRings17;
gameBoard(square);
system("PAUSE");
cout << "After the second move to solving the game is
made, it looks like this: \n\n";
square[9][2]= localRings8;
square[7][0]= localRings18;
gameBoard(square);
system("PAUSE");
cout << "After the third move to solving the game is
made, it looks like this: \n\n";
square[8][2]= localRings7;
square[9][1]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the fourth move to solving the game is
made, it should look like this: \n\n";
square[9][1]= localRings9;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the fifth move to solving the game is
made, it should look like this: \n\n";
square[8][0]= localRings9;
square[8][2]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the sixth move to solving the game, it
should look like this: \n\n";
square[8][1]= localRings8;
square[9][2]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the seventh move to solving the game,
it should look like this: \n\n";
square[7][1]= localRings9;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the eighth move to solving the game, it
should look like this: \n\n";
square[9][2]= localRings10;
square[9][0]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the ninth move to solving the game, it
should look like this: \n\n";
square[7][1]= localRings18;
square[8][2]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the tenth move to solving the game, it
should look like this: \n\n";
square[8][1]= localRings19;
square[9][0]= localRings8;
gameBoard(square);
system("PAUSE");
cout << "After the eleventh move to solving the game,
it should look like this: \n\n";
square[8][2]= localRings19;
square[8][0]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the twelfth move to solving the game,
it should look like this: \n\n";
square[9][1]= localRings20;
square[8][2]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the thirteenth move to solving the
game, it should look like this: \n\n";
square[9][2]= localRings7;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the fourteenth move to solving the
game, it should look like this: \n\n";
square[7][2]= localRings8;
square[9][0]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the fifteenth move to solving the game,
it should look like this: \n\n";\
square[6][2]= localRings7;
square[9][1]= localRings20;
gameBoard(square);
cout << "That was the way a win with four rings should
look\n\n";
system("PAUSE");
} //end if(choiceRings == 4)
}// end void playGame(char square[10][3])
//game board
void gameBoard(char square[10][3])
{
// gives each empty space on the board a dimension
cout << " THE TOWERS OF
HANOI\n";
cout << "
_______________________________________________________________________\n";
cout << "| |
| |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[0][0]<<" |
"<<square[0][1]<<" |
"<<square[0][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[1][0]<<" |
"<<square[1][1]<<" |
"<<square[1][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[2][0]<<" |
"<<square[2][1]<<" | "<<square[2][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[3][0]<<" |
"<<square[3][1]<<" | "<<square[3][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[4][0]<<" |
"<<square[4][1]<<" | "<<square[4][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[5][0]<<" |
"<<square[5][1]<<" | "<<square[5][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[6][0]<<" |
"<<square[6][1]<<" | "<<square[6][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[7][0]<<" |
"<<square[7][1]<<" | "<<square[7][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[8][0]<<" | "<<square[8][1]<<"
| "<<square[8][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[9][0]<<" | "<<square[9][1]<<" |
"<<square[9][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "
-----------------------------------------------------------------------\n";
} //error message: parse error at end of input. ponits
to this line????
=====
Julio
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|