I'm writing a program for a user to create a list of favorite things, maintain it. I don't quite know how to have the program print the list back. My pseudocode, if that helps:
A program to list and store games
list functions for Getting their favorite games.
Include in main function
program has a max of 5-10 favorite games it can store
User must be prompted to
List favorite games
user lists favorite games
program stores favorite games then prints them
Vector->Games
Vector->List
PseudoCode2
main function ()
run list function ()
return 0;
func list ()
define variables (not actually endented, just for clarity)
integer: currentGames; //the number of current games
vector or function?: listGames; //the list of games
user input(vector, string or int?): userGames; //the user input of the games
integer: maxGames; //the total number of games allowed
integer yesNo; //user input for a yes/no question
main operation
cout<<"would you like to make a list of your favorite games?(y/n)"<<endl; //asks the user to input a list of games
cin>>yesNo;
while (yesNo == 'y' && currentGames <= maxGames)
version 1:
{
function listGames()
{
cout<<"Input one of your favorite games: \n"
cin>>userGames;
list the games with a switch;
switch
{
1-10 for games. 1,2,3 for decision.
decision: 1: keep as is. 2: move to new location (++ or --); 3: delete, erase()+(#-1)
break
{
{
{
listGames;
{
main operation version 2:
while (yesNo == 'y' && currentGames <= maxGames)
{
cout<<"Input one of your favorite games: \n";
cin>>userGames;
list games;
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <list>
using namespace std;
void list();
int main ()
{
cout<<"Type in some of your favorite games: \n";
list();
return 0;
}
void list()
{
int faveGame;
int yesNo;
vector<string> listGame;
int maxGames = 10;
int currentGames = 0;
cout<<"Do you want to input some of your favorite games(y/n): ";
cin>>yesNo;
if (yesNo == 'y' && currentGames<=maxGames)
{
cout<<"Input one of your favorite games now: \n\n";
cin>>faveGame;
listGame.push_back(faveGame);
}
|