RE: [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: Ioannis V. <no...@ya...> - 2001-07-21 23:36:13
|
Basically class Rings is a whole mistake. You define const built in
arrays in the constructor, and you probably want to define them as
members of the class. You initialize them before their definition in the
constructor (as you should if they were defined as members of the
class), and you initialize in the wrong way. The initialization goes
=3D"string"; or=3D{values} and not ("string"). Perhaps it is better to
define the arrays as char const *const pointers pointing to "string"
where you could use the () notation.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Julio Lajara
> Sent: Sunday, July 22, 2001 12:42 AM
> To: dev...@li...
> Subject: [Dev-C++] I dont see the error in my code, I need=20
> help with this.......
>=20
>=20
> 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.
>=20
> #include <iostream.h>
> #include <stdlib.h>
> #include "Tower Ring Class.hpp"
>=20
> //function prototypes
>=20
> void gameBoard(char square[10][3]);
> void playGame(char square[10][3]);
>=20
> //This class creates te rings that will be placed on
> the gameBoard
>=20
> class Rings
> {
> Rings():
> rings1[4]("777"),=20
> 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];=20
> 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(){} =20
>=20
> };
>=20
> int main()
> {
>=20
> while(true)
> {
> // main menu
> char square[10][3];
> int choice;
> cout << " THE TOWERS OF=20
> HANOI\n\n";
> cout << " =20
> **********************************************************\n\n";
> cout << " *MENU OF
> CHOICES*\n\n"; =20
> cout << " (1)About THE TOWERS
> OF HANOI\n\n";
> cout << " (2)Object of THE
> TOWERS OF HANOI\n\n"; =20
> cout << " (3)Rules of THE
> TOWRERS OF HANOI\n\n"; =20
> cout << " (4)Play\n\n"; =20
> =20
> cout << " (5)Exit\n\n\n"; =20
> =20
> cout << " Please enter your
> choice: "; =20
> cin >> choice; =20
> =20
> cout << "\n\n =20
> **********************************************************\n\n";
>=20
> switch(choice)
> {
> case 1: cout << " About
> THE TOWERS OF HANOI\n\n";
> cout << "The ancient puzzle of=20
> 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;
>=20
> case 2: cout << " Objective
> of THE TOWERS OF HANOI\n\n";
> cout << "The objective of this=20
> puzzle is to
> move all the disks to the last peg.\n\n";
> system("PAUSE");
> continue;
>=20
> case 3: cout << " Rules of
> THE TOWERS OF HANOI\n\n";
> cout << "The rules are that only=20
> 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;
>=20
> case 4: playGame(square);
> break;
>=20
> case 5: break;
>=20
> default: break;
>=20
> } //end switch
>=20
>=20
> break;
> }//end while(true)
>=20
> return 0;
>=20
> }//end main()
>=20
> void playGame(char square[10][3])
> {
> =09
> //menu
> int choiceRings;
> cout << " THE TOWERS OF
> HANOI\n";
> cout <<=20
> "*************************************************************
> **********************\n\n\n";
> cout << "\nHow many rings would you like there to be?
> (min. 4, max. 10): ";
>=20
> cin >> choiceRings;
> =09
> cout << "\n\n";
> //only choice for now
> if(choiceRings =3D=3D 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=3D Aring.rings1;
> localRings2=3D Aring.rings2;
> localRings3=3D Aring.rings3;
> localRings4=3D Aring.rings4;
> localRings5=3D Aring.rings5;
> localRings6=3D Aring.rings6; =20
> localRings7=3D Aring.rings7;
> localRings8=3D Aring.rings8;
> localRings9=3D Aring.rings9;
> localRings10=3D Aring.rings10;
> localRings11=3D Aring.rings11;
> localRings12=3D Aring.rings12;
> localRings13=3D Aring.rings13;
> localRings14=3D Aring.rings14;
> localRings15=3D Aring.rings15;
> localRings16=3D Aring.rings16;
> localRings17=3D Aring.rings17;
> localRings18=3D Aring.rings18;
> localRings19=3D Aring.rings19;
> localRings20=3D Aring.rings20;
> square[0][0]=3D localRings11;
> square[1][0]=3D localRings12;
> square[2][0]=3D localRings13;
> square[3][0]=3D localRings14;
> square[4][0]=3D localRings15;
> square[5][0]=3D localRings16;
> square[6][0]=3D localRings7;
> square[7][0]=3D localRings8;
> square[8][0]=3D localRings9;
> square[9][0]=3D localRings10;
> square[0][1]=3D localRings11;
> square[1][1]=3D localRings12;
> square[2][1]=3D localRings13;
> square[3][1]=3D localRings14;
> square[4][1]=3D localRings15;
> square[5][1]=3D localRings16;
> square[6][1]=3D localRings17;
> square[7][1]=3D localRings18;
> square[8][1]=3D localRings19;
> square[9][1]=3D localRings20;
> square[0][2]=3D localRings11;
> square[1][2]=3D localRings12;
> square[2][2]=3D localRings13;
> square[3][2]=3D localRings14;
> square[4][2]=3D localRings15;
> square[5][2]=3D localRings16;
> square[6][2]=3D localRings17;
> square[7][2]=3D localRings18;
> square[8][2]=3D localRings19;
> square[9][2]=3D localRings20;
>=20
> // 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);
>=20
> system("PAUSE");
>=20
> cout << "After the first move to solving the game with
> four rings is made, it looks like this: \n";
> square[9][1]=3D localRings7;
> square[6][0]=3D localRings17;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the second move to solving the game is
> made, it looks like this: \n\n";
> square[9][2]=3D localRings8;
> square[7][0]=3D localRings18;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the third move to solving the game is
> made, it looks like this: \n\n";
> square[8][2]=3D localRings7;
> square[9][1]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fourth move to solving the game is
> made, it should look like this: \n\n";
> square[9][1]=3D localRings9;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fifth move to solving the game is
> made, it should look like this: \n\n";
> square[8][0]=3D localRings9;
> square[8][2]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the sixth move to solving the game, it
> should look like this: \n\n";
> square[8][1]=3D localRings8;
> square[9][2]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the seventh move to solving the game,
> it should look like this: \n\n";
> square[7][1]=3D localRings9;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the eighth move to solving the game, it
> should look like this: \n\n";
> square[9][2]=3D localRings10;
> square[9][0]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the ninth move to solving the game, it
> should look like this: \n\n";
> square[7][1]=3D localRings18;
> square[8][2]=3D localRings9;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the tenth move to solving the game, it
> should look like this: \n\n";
> square[8][1]=3D localRings19;
> square[9][0]=3D localRings8;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the eleventh move to solving the game,
> it should look like this: \n\n";
> square[8][2]=3D localRings19;
> square[8][0]=3D localRings9;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the twelfth move to solving the game,
> it should look like this: \n\n";
> square[9][1]=3D localRings20;
> square[8][2]=3D localRings9;
> gameBoard(square);
> =09
> =09
> =09
> =09
> system("PAUSE");
>=20
> cout << "After the thirteenth move to solving the
> game, it should look like this: \n\n";
> square[9][2]=3D localRings7;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fourteenth move to solving the
> game, it should look like this: \n\n";
> square[7][2]=3D localRings8;
> square[9][0]=3D localRings20;
> gameBoard(square);
> =09
> =09
> system("PAUSE");
>=20
> cout << "After the fifteenth move to solving the game,
> it should look like this: \n\n";\
> square[6][2]=3D localRings7;
> square[9][1]=3D localRings20;
> gameBoard(square);
>=20
> cout << "That was the way a win with four rings should look\n\n";
> system("PAUSE");
>=20
> } //end if(choiceRings =3D=3D 4)
> }// end void playGame(char square[10][3])
>=20
> //game board
> void gameBoard(char square[10][3])
> {
> // gives each empty space on the board a dimension
> cout << " THE TOWERS OF
> HANOI\n";=20
> cout << "=20
> ______________________________________________________________
> _________\n";
> cout << "| | =20
> | |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[0][0]<<" | =20
> "<<square[0][1]<<" | =20
> "<<square[0][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[1][0]<<" | =20
> "<<square[1][1]<<" | =20
> "<<square[1][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[2][0]<<" | =20
> "<<square[2][1]<<" | "<<square[2][2]<<"=20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[3][0]<<" | =20
> "<<square[3][1]<<" | "<<square[3][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[4][0]<<" | =20
> "<<square[4][1]<<" | "<<square[4][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[5][0]<<" | =20
> "<<square[5][1]<<" | "<<square[5][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[6][0]<<" | =20
> "<<square[6][1]<<" | "<<square[6][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[7][0]<<" | =20
> "<<square[7][1]<<" | "<<square[7][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[8][0]<<" | "<<square[8][1]<<"
> | "<<square[8][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[9][0]<<" | "<<square[9][1]<<" |=20
> "<<square[9][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "=20
-----------------------------------------------------------------------\
n";
> } //error message: parse error at end of input. ponits
> to this line????
>=20
> =3D=3D=3D=3D=3D
> Julio
>=20
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with=20
> Yahoo! Messenger http://phonecard.yahoo.com/
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|