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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
//A program that controls a list of chores
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <ctime>
#include <windows.h>
using namespace std;
string addGame, removeGame,addPerson;
vector<string> gameList,people;
vector<string>::iterator gameIter,personIter;
unsigned seed = time(NULL);
void reset();
int x=0, old, userSelection = 0, numberOfGames = gameList.size(), a=0, kids_number, choredivisions,kidsorg,cv=0;
void chore_assigner()
{
printf("How many kids are here?");
cin >> kids_number;
kidsorg=kids_number;
choredivisions=numberOfGames/kids_number;
while(kidsorg<6){
shuffle (gameList.begin(), gameList.end(),default_random_engine(seed));
while(0!=kids_number){
cout << "Who is here?\n";
cin.get();
getline(cin, addPerson);
people.push_back(addPerson);
cin.clear();
cin.sync();
kids_number--;
}
kids_number=0;
cout << endl<<endl;
while(cv!=kidsorg){
personIter=people.begin();
gameIter = gameList.begin();
cout <<"\t"<< *personIter <<" has:\n"<< endl;
while (a!=choredivisions) {
cout <<"\t"<< *gameIter << endl;
gameIter++;
a++;
}
system("pause");
a=0;
cv++;
personIter++;
}cout << "Unassigned Chore: " << *gameIter << endl;
Sleep(3000);
kidsorg=0;
}
numberOfGames=gameList.size();
reset();
}
int main()
{
gameList.push_back("Sweep LR");
gameList.push_back("Sweep Hall");
gameList.push_back("Chrome");
gameList.push_back("Trash");
gameList.push_back("Kids Bathroom Toilet");
gameList.push_back("Kids Bathroom Sink, Counter, and Mirror");
gameList.push_back("1st Floor Bathroom Floor");
gameList.push_back("1st Floor Bathroom Sink and Mirror");
gameList.push_back("1st Floor Bathroom Toilet");
//gameList.push_back("");
numberOfGames = gameList.size();
cout << "Welcome to your Chore List!\n" << endl;
while (userSelection != 5) {
cout << "Press 1 to add a Chore\n";
cout << "Press 2 to remove a Chore\n";
cout << "Press 3 to list all Chores\n";
cout << "Press 4 to assign chores\n";
cout << "Press 5 to quit\n" << endl;
cout << "Type your option: ";
cin >> userSelection;
switch (userSelection) {
case 1: // Add a title!
cout << "\nType the names title to add: ";
cin.get();
getline(cin, addGame);
gameList.push_back(addGame);
cin.sync();
numberOfGames++;
cout << "\nChore successfully added.\n" << endl;
x++;
old=x;
system("pause");
system("cls");
break;
case 2: // Remove a title!
for (gameIter = gameList.begin(); gameIter != gameList.end(); ++gameIter) {
cout <<"\t"<< *gameIter << endl;
}
cout << "\nType the Chores Exact title to remove.";
cin.get();
getline(cin, removeGame);
gameIter = find(gameList.begin(), gameList.end(), removeGame);
if (removeGame == *gameIter) {
cout << "\nChore found!" << endl;
gameList.erase(gameIter);
numberOfGames--;
cout << "Chore removed!\n" << endl;
}
else{
cout << "Chore not found\n";
}
system("pause");
system("cls");
break;
case 3: //List Chores
x=old;
numberOfGames = gameList.size();
cout << "\nYou currently have " << numberOfGames << " Chores in your list.\n" << endl;
for (gameIter = gameList.begin(); gameIter != gameList.end(); ++gameIter) {
cout <<"\t"<< *gameIter << endl;
}
cout << "\n";
system("pause");
system("cls");
break;
case 4: //Assign Chores
chore_assigner();
system("cls");
break;
case 5:
cout << "Program shutdown.\n" << endl;
system("cls");
a=5;
while (a!=0){
cout << a;
Sleep(1000);
system("cls");
a--;
}
return a;
break;
default:
cout << "\nThat is not a valid selection.\n" << endl;
break;
}}
return a;
}
void reset()
{
gameList.clear();
Sleep(2000);
printf("Please Press Five");
system("cls");
main();
}
|