Quaternity
Functions
input.cpp File Reference

This file defines user input functions. More...

#include <iostream>
#include <limits>
#include "settings.h"
#include "input.h"

Go to the source code of this file.

Functions

void flush ()
 Flush the input stream so it is empty for the next user input. More...
 
Question ask_question ()
 Ask the user to provide a question. More...
 
Answer ask_answer ()
 Ask the user to provide an answer. More...
 

Detailed Description

This file defines user input functions.

Definition in file input.cpp.

Function Documentation

◆ ask_answer()

Answer ask_answer ( )

Ask the user to provide an answer.

Definition at line 37 of file input.cpp.

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 }
void flush()
Flush the input stream so it is empty for the next user input.
Definition: input.cpp:16
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

◆ ask_question()

Question ask_question ( )

Ask the user to provide a question.

Definition at line 25 of file input.cpp.

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 }
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

◆ flush()

void flush ( )

Flush the input stream so it is empty for the next user input.

Definition at line 16 of file input.cpp.

17 {
18  std::cin.clear();
19  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
20 }