Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <vector>
#include <string>
#include "arrowDisplay.h"
#define KEY_UP 72
#define KEY_DOWN 80
//Inputted a vector of values and will display them in a menu type manner
//and return the question they selected
std::string Display(std::vector<std::string> values)
{
bool entered = false;
int arrow = 0;
std::string output;
//Initilises screen
Draw(values, arrow, entered);
//Tests to see if any values have been selectd. If not it will continue
while (!entered)
{
if(_kbhit())
{
//Sees if arrow keys or enter has been pressed and moves arrow up and down
char c = _getch();
if (c == 0)
{
switch(_getch())
{
//Sees if up arrow has been pressed
case KEY_UP:
arrow--;
if (arrow < 0)
{
arrow = values.size()-1;
Draw(values, arrow, entered);
}
else
Draw(values, arrow, entered);
break;
//Sees if down arrow has been pressed
case KEY_DOWN:
arrow++;
if (arrow >= values.size())
{
arrow = 0;
Draw(values, arrow, entered);
}
else
Draw(values, arrow, entered);
break;
}
}
else
switch(c)
{
//Sees if enter has been pressed
case '\r':
entered = true;
output = Draw(values, arrow, entered);
system("cls");
//cout << "\n " << output << "\n" << endl;
break;
}
}
}
return output;
}