Quaternity
input.cpp
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <limits>
9 
10 #include "settings.h"
11 #include "input.h"
12 
16 void flush()
17 {
18  std::cin.clear();
19  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
20 }
21 
26 {
27  std::cout << "Please provide a question (player, set, card)." << std::endl << "> ";
28  Question question;
29  std::cin >> question.player >> question.set >> question.card;
30  flush();
31  return question;
32 }
33 
38 {
39  std::cout << "Please provide your answer (0/1)." << std::endl << "> ";
40  Answer answer;
41  std::cin >> answer;
42  flush();
43  return answer;
44 }
Answer ask_answer()
Ask the user to provide an answer.
Definition: input.cpp:37
Question ask_question()
Ask the user to provide a question.
Definition: input.cpp:25
void flush()
Flush the input stream so it is empty for the next user input.
Definition: input.cpp:16
This file defines user input function headers.
bool Answer
An answer returned by a player. The answer is either true or false denoting he/she has or does not ha...
Definition: round.h:39
This file defines the settings struct.
A question asked by a player. The player asks another player for a specific card from a certain set.
Definition: round.h:17
int set
The set the card which is asked belongs to.
Definition: round.h:27
int player
The player the question is asked to.
Definition: round.h:22
int card
The card in the set which is asked for.
Definition: round.h:32