#pragma warning(disable:4786)
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <stack>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include "car.h"
using namespace std;
const int PARKING_SPOTS_PER_AISLE = 3;
const int NUMBER_OF_AISLES = 5;
void handle_arrival(vector<Car>&, vector<stack<string> >&, const string&);
void handle_departure(vector<Car>&, vector<stack<string> >&, const string&);
Car& find_car(vector<Car>&, string);
bool compare(Car c_1, Car c_2); //declare the function
int main(int argc, char* argv[]) {
try {
if (argc != 2) {
cerr << "Usage:\n" << argv[0] << " data-file";
return EXIT_FAILURE;
}
ifstream inf(argv[1]);
if (! inf) {
cerr << "Could not open " << argv[1];
return EXIT_FAILURE;
}
vector<Car> cars;
vector< stack<string> > parking_lot(NUMBER_OF_AISLES);
while (! inf.eof()) {
string action, plate;
inf >> plate >> action;
if (action == "arrives") {
handle_arrival(cars, parking_lot, plate);
}
else if (action == "departs") {
handle_departure(cars, parking_lot, plate);
} else {
cerr << "Unknown action: " << action << endl;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <stack>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include "car.h"
using namespace std;
const int PARKING_SPOTS_PER_AISLE = 3;
const int NUMBER_OF_AISLES = 5;
void handle_arrival(vector<Car>&, vector<stack<string> >&, const string&);
void handle_departure(vector<Car>&, vector<stack<string> >&, const string&);
Car& find_car(vector<Car>&, string);
bool compare(Car c_1, Car c_2); //declare the function
int main(int argc, char* argv[]) {
try {
if (argc != 2) {
cerr << "Usage:\n" << argv[0] << " data-file";
return EXIT_FAILURE;
}
ifstream inf(argv[1]);
if (! inf) {
cerr << "Could not open " << argv[1];
return EXIT_FAILURE;
}
vector<Car> cars;
vector< stack<string> > parking_lot(NUMBER_OF_AISLES);
while (! inf.eof()) {
string action, plate;
inf >> plate >> action;
if (action == "arrives") {
handle_arrival(cars, parking_lot, plate);
}
else if (action == "departs") {
handle_departure(cars, parking_lot, plate);
} else {
cerr << "Unknown action: " << action << endl;
}