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
|
#include <iostream>
#include <string>
#include <list>
#include "ListP.h"
#include "ListP.cpp"
using namespace std;
int main ()
{
string a,b,c,e,h;
int f=1;
int g;
int i = 0;
list<string> lane1(10), lane2(10);
while (a!="x" || a!="X")
{
cout << "Welcome to the parking lot! \n \n";
cout << "If your picking up a car press P \n";
cout << "If your dropping off a car press D \n";
cout << "To view all the cars in the lot press V \n";
cout << "Or to exit press X \n \n";
cin >> a;
if(!(a=="P"||a=="p"||a=="d"||a=="D"||a=="V"||a=="v"||a=="X"||a=="x"))
{
cout<< "Im sorry but thats an incorrect input \n";
return 0;
}
if(a=="x"||a=="X")
{
break;
}
else if (a=="D"||a=="d")
{
cout<< "Please enter the vehicle license plate";
cin>> b;
if((lane1.size) < 10)
{
lane1.insert(1,b);
cout<< "You are parked in lane 1";
}
else if((lane2.size) < 10)
{
lane2.insert(1,b);
cout<< "You are parked in lane 2";
}
else if (lane1.size && lane2.size > 10)
{
cout<<"The lots are full, please come back later";
}
}
else if (a=="p"||a=="P")
{
cout << "These are the cars in the lot";
while ((lane1.size) > 1)
{
cout<< "The license plates in lane 1 are ";
while (f < 10)
{
lane1.retrieve(f, b);
cout<< b << ", ";
f++;
}
}
f=1;
cout<< endl;
while ((lane2.size) > 1)
{
cout<< "and the license plates in lane 2 are ";
while (f < 10)
{
lane2.retrieve(f, b);
cout<< b << ", ";
f++;
}
}
f=1;
cout<< "If you are parked in lane 1 press 1, if your parked in lane 2 press 2" << endl;
cin >> g;
while (g==1)
{
lane1.retrieve(f,b);
cout<< "Is your plate number " << b << "?";
cin >> h;
if (h=="y")
{
lane1.remove(f);
break;
break;
}
while (h=="n")
{
f++;
lane1.retrieve(f,b);
cout<< "How about " << b << "?" << endl;
cin >> h;
}
break;
}
while (g==2)
{
lane2.retrieve(f,b);
cout<< "Is your plate number " << b << "?";
cin >> h;
if (h=="y")
{
lane2.remove(f);
break;
break;
}
while (h=="n")
{
f++;
lane2.retrieve(f,b);
cout<< "How about " << b << "?" << endl;
cin >> h;
}
break;
}
break;
}
}
return 0;
}
|