Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed for you
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:f267d0dc8ad22dde237d5fa92ff4f3aa83c6d1daf8792d2181ca7df405b8daa1
User & Date: zie 2018-05-18 18:31:36
Context
2018-05-18
18:49
xPos fixed check-in: f08571ec15 user: sarah tags: trunk
18:31
fixed for you check-in: f267d0dc8a user: zie tags: trunk
18:17
Debugging statements check-in: 39b76ecfcc user: sarah tags: trunk
Changes

Changes to finalproject/finalproject.cpp.

90
91
92
93
94
95
96
97
98

99
100
101


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160

class MyPickUpGame: public PickUpGame
{ public:  
      
void BoundedMove(char UserMove)
{ 

cout<<"xPos="<<xPos<<" yPos="<<yPos;


if ((xPos> -1) && (xPos<20) && (yPos>-1) && (yPos<40))
{
 


       if(xPos<1)
 {cout << "xPos <1, resetting back to 1";
       xPos=1;
       cout<<"xPos="<<xPos<<" yPos="<<yPos;
 }
 if(xPos>18)
{cout << "xPos > 19, resetting back to 19";
      xPos=18;
      cout<<"xPos="<<xPos<<" yPos="<<yPos;
}
if(yPos<0)
{cout << "yPos< 0, resetting back to 0";
      yPos=0;
      cout<<"xPos="<<xPos<<" yPos="<<yPos;
}
if(yPos>39)
{cout << "yPos > 39, resetting back to 39";
      yPos=39;
      cout<<"xPos="<<xPos<<" yPos="<<yPos;
}
     
}
cout<<"xPos="<<xPos<<" yPos="<<yPos;
Move(UserMove);
     
}




};

//You can modify and change main()
int main()
{


      MyPickUpGame* Game = new MyPickUpGame; //Create a new game object and store it in a object pointer

      char UserMove = ' '; //This is used to store the users input
      do {
           system("clear"); //Clear the screen before printing anything
           cout << "Welcome to cookie pickup. You will move to the cookies by using the arrow keys." << endl; //Program intro
           Game->Print(); //Print the grid out
           cout << "What direction would you like to move in? \n(Move using the arrow keys or type q to quit.) "; //Instructions to the user
           //UserMove = getche(); //Get one character from the user (some compilers have "getche()")
            system("/bin/stty raw"); 
           UserMove = getchar(); //Get one character from the user (Visual Studio 2010 "_getche()" is the new version of "getche()")
     	      system("/bin/stty cooked");
           Game->BoundedMove(UserMove); //Process the users input
      } while(UserMove != 'Q' && UserMove != 'q'); //Keep running the program until the user types in a Q or q

      system("clear"); //Clear the screen
      cout << endl;
      Game->Print(); //Print the final grid out to the user
      cout << endl;

      
      return 0;
}







|
<
>
|
|
<
>
>
|
|

<


|

<


|

<


|

<


<
|
<











>





<










|







90
91
92
93
94
95
96
97

98
99
100

101
102
103
104
105

106
107
108
109

110
111
112
113

114
115
116
117

118
119

120

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

class MyPickUpGame: public PickUpGame
{ public:  
      
void BoundedMove(char UserMove)
{ 

cout<< "\nbefore usernove:" << "xPos="<<xPos<<" yPos="<<yPos << "\n";

Move(UserMove);
cout<< "after usernove:" << "xPos="<<xPos<<" yPos="<<yPos << "\n";


// When you reset a xPos, you have to clear the character at the old location first.
// you are not doing that here... yet :)
if(xPos<1)
 {cout << "xPos <1, resetting back to 1\n";
       xPos=1;

 }
 if(xPos>18)
{cout << "xPos > 19, resetting back to 19\n";
      xPos=18;

}
if(yPos<0)
{cout << "yPos< 0, resetting back to 0\n";
      yPos=0;

}
if(yPos>39)
{cout << "yPos > 39, resetting back to 39\n";
      yPos=39;

}
     

cout << "move end" <<"xPos="<<xPos<<" yPos="<<yPos << "\n";

     
}




};

//You can modify and change main()
int main()
{
      system("clear"); //Clear the screen before printing anything

      MyPickUpGame* Game = new MyPickUpGame; //Create a new game object and store it in a object pointer

      char UserMove = ' '; //This is used to store the users input
      do {

           cout << "Welcome to cookie pickup. You will move to the cookies by using the arrow keys." << endl; //Program intro
           Game->Print(); //Print the grid out
           cout << "What direction would you like to move in? \n(Move using the arrow keys or type q to quit.) "; //Instructions to the user
           //UserMove = getche(); //Get one character from the user (some compilers have "getche()")
            system("/bin/stty raw"); 
           UserMove = getchar(); //Get one character from the user (Visual Studio 2010 "_getche()" is the new version of "getche()")
     	      system("/bin/stty cooked");
           Game->BoundedMove(UserMove); //Process the users input
      } while(UserMove != 'Q' && UserMove != 'q'); //Keep running the program until the user types in a Q or q

      // system("clear"); //Clear the screen
      cout << endl;
      Game->Print(); //Print the final grid out to the user
      cout << endl;

      
      return 0;
}