Hey my name is Justen and I'm a first semester C++ student and im working on some code that needs some help. For some reason it wont execute anything anymore and i have no idea why. It was going along fine before i started adding the balance functions. I tried commenting things out and I cant find the source of the problem. Please help. Any help is appreciated! here is the code...
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
//capitalized customer first and last name
//capitalized customer movies
//screened user choice
//submenu for print
//handle movies with spaces
//return specific movies
//add more than one customer at a time
//screen for bad input for everything
//ask are you sure you really want to save or delete and load
//movie database no more than 10
//incorporate money
//free rental for specific event
//movie ratings with age check
//plus sell at register (Candy, Popcorn...)
//dependents
//better interface
//differnt sort routines (age, how many movies )
//focus searches
//add a password for certain menus
//sub menus for print, sort, rent movie
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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
|
class customers
{
private:
string storeName;
string first [ 100 ];
string last [ 100 ];
int age [ 100 ];
string movies[100][10];
int howManyMovies[100];
int howMany;
//int balance[100];
public:
customers();
void add();
void printSubMenu();
void printAll();
void printMinors();
void printAdults();
void printPeopleMovies();
void save();
void load();
void remove();
//void sortAlpha();
//void sortSubMenu();
//void sortAgeHigh();
//void sortAgeLow();
//void sortAmountOfMovies();
void swap( int which );
void rent();
void returnMovies();
void intro();
void printMovies();
//void payBalance();
};
customers::customers()
{
storeName = "Justen's Movies";
howMany = 0;
};
void customers::intro()
{
cout << " Welcome to Justen's Movies!! " << endl;
for ( int i = 0; i <= 3; i ++ )
{
for ( int j = 0; j < 80; j ++ )
{
cout << "#";
}
}
cout << endl;
return;
};
void customers::sortSubMenu()
{
int choice;
system("cls");
cout << " How would you like them sorted? " << endl
<< "0 - Alphabetically " << endl
<< "1 - Age (starting high and going down) " << endl
<< "2 - Age (starting low and going up) " << endl
<< "3 - Amount of Movies " << endl
<< "What is your choice? " << endl;
cin >> choice;
while( cin.fail() || choice < 0 || choice > 3)
{
cin.clear(); // reset the state bits back to goodbit so we can use ignore()
cin.ignore(1000, '\n');
cout << "Sorry invalid choice...try again : ";
cin >> choice;
}
switch ( choice )
{
case 0:
sortAlpha();
break;
case 1:
sortAgeHigh();
break;
case 2:
sortAgeLow();
break;
case 3:
sortAmountOfMovies();
break;
default:
break;
}
return;
};
void customers::sortAgeHigh()
{
for ( int i = 0; i < howMany - 1; i ++ )
{
for ( int j = 0; j < howMany - 1 - i; j ++ )
{
if ( age[j] < age[j+1] )
swap(j);
}
}
return;
};
void customers::sortAgeLow()
{
for ( int i = 0; i < howMany - 1; i ++ )
{
for ( int j = 0; j < howMany - 1 - i; j ++ )
{
if ( age[j] > age[j+1] )
swap(j);
}
}
return;
};
void customers::sortAmountOfMovies()
{
for ( int i = 0; i < howMany - 1; i ++ )
{
for ( int j = 0; j < howMany - 1 - i; j ++ )
{
if ( howManyMovies[j] < howManyMovies[j+1] )
swap(j);
}
}
return;
};
void customers::sortAlpha()
{
for ( int i = 0; i < howMany - 1; i ++ )
{
for ( int j = 0; j < howMany - 1 - i; j ++ )
{
if ( first[j] > first[j+1] )
swap(j);
}
}
for ( int i = 0; i < howMany - 1; i ++ )
{
for ( int j = 0; j < howMany - 1 - i; j ++ )
{
if ( last[j] > last[j+1] )
swap(j);
}
}
return;
};
void customers::swap( int which )
{
string strTemp;
int intTemp;
strTemp = first[which];
first[which] = first[which + 1];
first[which + 1] = strTemp;
strTemp = last[which];
last[which] = last[which + 1];
last[which + 1] = strTemp;
intTemp = age[which];
age[which] = age[which + 1];
age[which + 1] = intTemp;
intTemp = balance[which];
balance[which] = balance[which + 1];
balance[which + 1] = intTemp;
for ( int j = 0; j < howManyMovies[which]; j ++ )
{
strTemp = movies[which][j];
movies[which][j] = movies[which + 1][j];
movies[which + 1][j] = strTemp;
}
intTemp = howManyMovies[which];
howManyMovies[which] = howManyMovies[which + 1];
howManyMovies[which + 1] = intTemp;
return;
};
void customers::add()
{
system("cls");
printAll();
string saveAnswer;
string answer;
do{
cout << "First name : ";
cin >> first[howMany];
first[howMany][0] = toupper(first[howMany][0]);
cout << "Last name : ";
cin >> last[howMany];
last[howMany][0] = toupper(last[howMany][0]);
cout << "Age : ";
cin >> age[howMany];
cout << "Would you like to save? : ";
cin >> saveAnswer;
if ( saveAnswer == "yes" || saveAnswer == "Yes" )
{
save();
}
cout << "Would you like to add another? : ";
cin >> answer;
}while( answer == "yes" || answer == "Yes" );
howManyMovies[howMany] = 0;
//balance[howMany] = 0;
howMany ++;
return;
};
void customers::remove()
{
int which;
string answer;
printAll();
cout << endl << "Are you sure you want to do this? : ";
cin >> answer;
if ( answer == "yes" || answer == "Yes" )
{
cout << "Which customer do you wish to remove? : ";
cin >> which;
for ( int i = which; i < howMany - 1; i ++ )
{
first[i] = first[i+1];
last[i] = last[i+1];
age[i] = age[i+1];
//balance[i] = balance[i+1];
for ( int j = 0; j < howManyMovies[i+1]; j ++ )
{
movies[i][j] = movies[i+1][j];
}
howManyMovies[i] = howManyMovies[i+1];
}
howMany --;
}
return;
};
|