![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
so here is the source im doing as a weeekly assignment for my class(extra credit) and i gave it a shot and i couldnt seem a way to do it. here is my shot at it could u plz tell me errors and maybe a way to fix it
//Mason Dructor
#include <string>
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
int main()
{
cout<<"\t\t\tGame Storage Pro\n\n";
cout<<"Welcome, what would you like to do?";
string input;
vector<string> library;
vector<string> gamename;
while(input != "quit")//main program loop
{
cout<<"\n\nIf you want to add a game to the list just type in 'add'.\n";
cout<<"To see your library type in 'library'.\n";
cout<<"To remove a game type in 'remove'.\n";
cout<<"To quit type in 'quit'\n";
cin>> input;
input = toupper(input);
cout<<"You chosed to "<<input.c_str<<".";
vector<string>::const_iterator iter;
if(input == "LIBRARY")
{
for(iter = library.begin(); iter != library.end(); ++iter)
cout << endl << endl << *iter << endl << endl;
}
string add;
if(input == "ADD")
{
cout<<"\n\nType the name of the game you would like to\n";
cout<<"your library.\n";
cin>>gamename;
gamename = toupper(gamename);
library.insert(library.begin(), gamename);
cout<<"You successfully added "<<gamename<<" to your library!\n\n";
}
if(input == "REMOVE")
{
cout<<"\n\nType the name of the game you want to remove.\n";
cin>>gamename;
gamename = toupper(gamename);
gamename.clear();
cout<<"\nYou successfully removed "<<gamename<<" from the library.";
}
return 0;
} |
|
|
|
|
|
#2 |
|
Newbie
|
ok i got one part,
gamename doesnt need to be vector, only library does ne other tips |
|
|
|
|
|
#3 |
|
Newbie
|
ok i got it, just took a few mins looking at it
//Mason Dructor
#include <string>
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
int main()
{
cout<<"\t\t\tGame Storage Pro\n\n";
cout<<"Welcome, what would you like to do?";
string input;
vector<string> library;
string gamename;
int i;
string add;
int number;
vector<string>::const_iterator iter;
while(input != "quit")//main program loop
{
cout<<"\n\nIf you want to add a game to the list just type in 'add'.\n";
cout<<"To see your library type in 'library'.\n";
cout<<"To remove a game type in 'remove'.\n";
cout<<"To quit type in 'quit'\n";
cin>>input;
cout<<"You chose "<<input.c_str()<<".";
if(input == "LIBRARY" || input == "Library" || input == "library")
{
for(iter = library.begin(); iter != library.end(); ++iter)
cout << endl << endl << *iter << endl;
}
if(input == "ADD" || input == "Add" || input == "add")
{
cout<<"\n\nType the name of the game you would like to add";
cout<<"your library.\nMake sure to make the game one word!\n";
cin>>gamename;
library.insert(library.begin(), gamename);
cout<<"You successfully added "<<gamename<<" to your library!\n\n";
}
if(input == "REMOVE" || input == "Remove" || input == "remove")
{
"/n/nType in the number of the game to remove it from the library.\n\n";
for(iter = library.begin(); iter != library.end(); ++iter)
cout<<endl<< *iter <<endl;
cout<<"\n";
cin>>number;
library.erase((library.begin() + number - 1));
cout<<"You succesfully removed " << library[number - 1]<<" from the library.";
}
}
return 0;
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|