//Ask the user a yes/no question bool ask(char question[]) { bool answer = true; //Ask the question on screen LCD.WriteRC(question, 3, 0); LCD.WriteAt("Yes", 70, 130); LCD.WriteAt("No", 190, 130); float x, y; //Wait until the user presses the screen while(!LCD.Touch(&x,&y)); //Take user input, false = no if(x > 130) { answer = false; } Sleep(100); LCD.Clear( FEHLCD::Black ); return answer; }
Algorithm for ask:
- Set the answer to true.
- Write the question on the screen, and an option for yes or no.
- Wait until user touches the screen.
- If the user selects no, set answer equal to false.
- Return answer.
- End function.