Here's what I have please tell me if I have to post everything. What I want is if they type " tcc fcc (enter)" I want cube.rotateTopNeg90() then cube.rotateFrontNeg90() to work on the cube thats printed. edit: Sorry, that's my question above, right now the commands only work one at a time (ie: 'tcc' (enter) 'fcc' (enter) ...) I want to it to be something like this ( 'tcc' 'fcc' 'tcc' 'tcc'....(repeat as many times as they like) (enter)) then each are processed consecutively. That's why I can't just use cin. I've asked this before here but I really don't know how to do it exactly.
class RubiksCube
{
public:
RubiksCube::RubiksCube() { /*stuff here*/ }
void display() { /*prints the cube unfolded here*/ }
void rotateTopNeg90() { /*moves top of the cube counterclockwise*/ }
void RubiksCube::rotateFrontNeg90() { /*moves front counterclockwise*/ }
}
//main
int main(int argc, char *argv[])
{
RubiksCube cube;
string s;
srand(time(0));
while (1)
{
string rotateTopNeg90 = "tcc";
string rotateFrontNeg90 = "fcc";
cube.display();
cout << "COMMAND:";
getline(cin,s);
istringstream stream(s);
if (s == rotateTopNeg90 )
cube.rotateTopNeg90();
if ( s == rotateFrontNeg90 )
cube.rotateFrontNeg90();
}
return 0;
}
cin << s;instead ofgetline(...)would do everything you want