Exemplo n.º 1
0
void MainWindow::on_NewReservation_clicked()
{
    if("" == ui->CustomerIdReservation->text() || "" == ui->RoomNumberReservation->text())
    {
        QMessageBox::about(0,Title,EmptyRes);
        ui->CustomerIdReservation->setFocus();
    }
    else
    {
        if(ui->CheckInDate->date() < QDate::currentDate())
        {
            QMessageBox::about(0,Title,DateBeforeCurrentDate);
            ui->CheckInDate->setDate(QDate(QDate::currentDate()));
        }
        else if(ui->CheckOutDate->date() < ui->CheckInDate->date())
        {
            QMessageBox::about(0,Title,CheckOutBeforeCheckIn);
            ui->CheckOutDate->setDate(ui->CheckInDate->date());
        }
        else
        {
            Room room;
            Customer customer;

            customer.setId(ui->CustomerIdReservation->text());
            room.setRoomNumber(ui->RoomNumberReservation->text().toInt());

            ResM.roomReservation(ui->CheckInDate->date(),ui->CheckOutDate->date(),room,customer);

            ui->CheckInDate->setDate(QDate(QDate::currentDate()));
            ui->CheckOutDate->setDate(QDate(QDate::currentDate()));
            ui->CustomerIdReservation->setText("");
            ui->RoomNumberReservation->setText("");
            ui->CustomerIdReservation->setFocus();
            showRoomGrid();
        }
    }
}
Exemplo n.º 2
0
JSBool JSCustomer::JSGetProperty(JSContext *cx, JSObject *obj, jsval id,
								 jsval *vp)
{
    if (JSVAL_IS_INT(id)) 
	{
		JSCustomer *p = (JSCustomer *) JS_GetPrivate(cx, obj);
		Customer *customer = p->getCustomer();
        switch (JSVAL_TO_INT(id)) 
		{
		case name_prop:
			{
				std::string name = customer->GetName();
				JSString *str = JS_NewStringCopyN(cx, name.c_str(), name.length());
				*vp = STRING_TO_JSVAL(str);
				break;
			}
		case age_prop:
			*vp = INT_TO_JSVAL(customer->GetAge());
			break;
        }
    }
    return JS_TRUE;
}
Exemplo n.º 3
0
JSBool JSCustomer::JSSetProperty(JSContext *cx, JSObject *obj, jsval id, 
								 jsval *vp)
{
    if (JSVAL_IS_INT(id)) 
	{
		JSCustomer *p = (JSCustomer *) JS_GetPrivate(cx, obj);
		Customer *customer = p->getCustomer();

        switch (JSVAL_TO_INT(id)) 
		{
		case name_prop:
			{
				JSString *str = JS_ValueToString(cx, *vp);
				std::string name = JS_GetStringBytes(str);
				customer->SetName(name);
				break;
			}
		case age_prop:
			customer->SetAge(JSVAL_TO_INT(*vp));
			break;
		}
    }
    return JS_TRUE;
}
Exemplo n.º 4
0
void TextFileDataSource::ConstructAndAddCustomer(std::string line)
{
	enum 
	{
		USER_ID,
		PASSWORD,
		NAME,
		ADDRESS,
		PHONE_NUMBER,
		ACCOUNT_IDS,
		NUM_FIELDS
	};
	
	vector<std::string> lineSplit = stringUtils::splitstring(line, ',');
	vector<std::string> accountIds = stringUtils::splitstring(lineSplit[ACCOUNT_IDS], ';');

	// create customer
	Customer* c = new Customer
	(
		TypeConverter(lineSplit[USER_ID]),
		lineSplit[PASSWORD],
		lineSplit[NAME],
		lineSplit[ADDRESS],
		lineSplit[PHONE_NUMBER]
	);

	// add account ids
	vector<std::string>::iterator vit;
	for (vit = accountIds.begin(); vit != accountIds.end(); ++vit)
	{
		c->addAccount(TypeConverter(*vit));
	}

	_users.add(c->getUserId(), c);

}
Exemplo n.º 5
0
// PUBLIC FUNCTIONS
bool MainWindow::addCustomerToList(Customer customer) {

    QString messageResult = _dbManager->addCustomer(customer);
    if( messageResult != NULL)
    {

        QMessageBox::critical(this, tr("Save attempt failed"), "Could not save \"" + customer.getCompanyName() + "\" into the database: \n" + messageResult);
        ui->statusBar->showMessage("Add to database unsuccessful: " + customer.getCompanyName());
        return false;
    } else {

        ui->statusBar->showMessage("Successfully added \"" + customer.getCompanyName() + "\" to the databse");

        // Close the current tab
        ui->tableTabWidget->removeTab(ui->tableTabWidget->currentIndex());

        // Open the company invoice tab
        QWidget *customerInvoiceTab = new AllCompanyInvoices(0, this, &customer);
        ui->tableTabWidget->setCurrentIndex(ui->tableTabWidget->addTab(customerInvoiceTab, customer.getCompanyName() + " Invoices"));
    }

    return true;

}
Exemplo n.º 6
0
void Server::startService(Customer& c){
	// pre: Q is not full and sim_->events is not full
	// post: start serving Customer c if available, otherwise puts c in Queue
	// Exception: _SERVER_QUEUEFULL if Q is full, _SERVER_EVENTSFULL if events is full
	if (!available()){
		if (!Q->enqueue(c)) throw _SERVER_QUEUEFULL;
	} else {
		// record stats
		waitTime += sim_->now() + c.time();
		lastStart = sim_->now();
		current = c;
		
		// reschedule
		busy = true;
		time_ = sim_->now() + (*exp)(*gen);
		if (sim_->insert(this)==_ORDEREDSET__SETFULL) throw _SERVER_EVENTSFULL;
	}
}
Exemplo n.º 7
0
void Bank::getAccountData(QString login, QString pass)
{
    string line;
    Customer* cus = &getCustomer("Customer", "Reach", "New York");
    cus->addDebitAccount(login.toStdString(), pass.toStdString());
    size_t moneyAmount(100500);
    cus->getDebitAccount().putMoney(moneyAmount);
    _accounts.push_back(&(cus->getDebitAccount()));

    size_t limit(10000);
    size_t getted(1000);

    cus->addCreditAccount(limit, login.toStdString(), pass.toStdString());
    cus->getCreditAccount().getMoney(getted);

    _accounts.push_back(&(cus->getCreditAccount()));
};
Exemplo n.º 8
0
bool DoubleLinkList::putCustomer (int s, int e, int o) {
    bool x = false;
    Customer* temp1;
    Customer A(o);

    temp1 = A.putOneCustomer (FwdListPointer, s, e, o);

    if (temp1 != NULL)
    {   if (FwdListPointer == NULL && RevListPointer == NULL)
            FwdListPointer = RevListPointer = temp1;
        else
        {
            FwdListPointer->putPriorPointer (temp1);
            FwdListPointer = temp1;
        }
        x = true;
    }
    return x;
}
Exemplo n.º 9
0
//--------------------------------Execute---------------------------------//
//this method performs the actions for the Borrow object, using the
//store as a parameter to access the inventory and alter accordingly
//it also uses the file stream to read in the information
//according to formatting specifications, setting it for this specified
//derived transaction class
bool Borrow::execute(ifstream& file, Store& st)
{
	int custIdx;
	file >> custIdx;
	Customer* cust = st.getCustomer(custIdx);
	//read the custtomer index and get the customer at that index
	//from the store, if the store doesn't have the customer at that
	//spot then the customer has not been created and we cannot do anything
	if (cust == NULL)
	{
		cout << "Invalid Customer ID. Transaction could not be executed.\n";
		//no need for clean up since Customer is still NULL
		return false;
	}
	else
	{
		char format;
		file >> format;
		//read in the format, the format is specified to only be DVDs
		if (format != 'D')
		{
			cout << "Invalid format. Transaction could not be executed.\n";
			//no need for clean up since Formaat is not dynamic
			return false;
		}
		else
		{
			char genre;
			file >> genre;
			//read in the genre and then use the stores movie factory
			//to create a temporary movie of this genre,
			//however, if the genre did not correspond to an appropriate
			//movie, return false
			Movie* tempMov = st.getMovieFact().createIt(genre);
			if (tempMov == NULL)
			{
				cout << "Invalid movie. Transaction could not be "
					<< "executed.\n";
				//no need for clean up since tempMov is still NULL
				return false;
			}
			else
			{
				//everything worked, now we try to set the data
				//from the format specifications of a borrow
				//movie, and if this didn't work, the movie was 
				//created so we must clean this up. otherwise, we try
				//to borrow the movie from the inventory
				if (!tempMov->readTrans(file))
				{
					delete tempMov;
					tempMov = NULL;
					return false;
				}
				else
				{
					Movie* mov = NULL;
					//use a movie locator and a movie return value
					//to try to borrow the movie from the stores
					//inventory, if the borrow couldn't occur
					//we must delete the temporary movie
					if (!st.getInventory().borrowMovie(mov, tempMov))
					{
						cout << "Invalid movie. Transaction could not be "
							<< "executed.\n";
						delete tempMov;
						tempMov = NULL;

						return false;
					}
					else
					{
						//otherwise everything has worked out so far
						//so we set the data of the borrow transaction
						//because we already know the movie
						//and the customer is accurate
						setData(cust, mov);
						//if we couldn't borrow we must clean up
						if (!cust->borrowMovie(mov))
						{
							cout << "Invalid movie." <<
								"Transaction could not be "
								<< "executed.\n";
							delete tempMov;
							tempMov = NULL;
							return false;
						}
						//otherwise everything worked out perfectly
						//so the data is set and the customer
						//adds this transaction to his/her trans hist
						//and clean up our temp mov
						cust->addTransaction(this);
						delete tempMov;
						tempMov = NULL;
						return true;
					}
				}
			}
		}
	}
}
Exemplo n.º 10
0
void CVRP::init(VRP V) {
	cout.setf(ios::fixed | ios::showpoint);
	cout.precision(2);
	std::cout.imbue(
			std::locale(std::cout.getloc(), new punct_facet<char, ','>));

	bool init1 = false;

	if (init1) {
		setNroCustomers(V.getBusStops().size() + 1);
		Customer depot(V.getCoorSchool().getX(), V.getCoorSchool().getY(),
				V.getCoorSchool().getCapacity());

		std::vector<Stop> a;
		a.insert(a.begin() + 0, V.getCoorSchool());
		std::vector<Stop> b = V.getBusStops();
		//Set AllCustomer but not depot
		std::vector<Customer> allCustNotDepot;
		for (size_t i = 0; i < V.getBusStops().size(); i++) {
			Stop stop = V.getBusStops().at(i);
			Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
			allCustNotDepot.insert(allCustNotDepot.begin() + i, customer);
		}
		setAllCustNoDepot(allCustNotDepot);

		a.insert(a.end(), b.begin(), b.end());
		std::vector<Customer> allCustomers;
		for (size_t i = 0; i < a.size(); i++) {
			Stop stop = a.at(i);
			Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
			allCustomers.insert(allCustomers.begin() + i, customer);
		}

		for (size_t i = 0; i < allCustomers.size(); i++) {
			Customer customer = allCustomers.at(i);
			cout << "(" << customer.getX() << ", " << customer.getY() << ", "
					<< customer.getDemand() << ")" << endl;
		}
		setDepot(depot);
		setAllCustomers(allCustomers);
		setK(V.getK());
		setC(V.getCk());
		setKmin(V.getKmin());
	} else {
		setNroCustomers(V.getBusAssigned().size() + 1);
		Customer depot(V.getCoorSchool().getX(), V.getCoorSchool().getY(),
				V.getCoorSchool().getCapacity());

		std::vector<Stop> a;
		a.insert(a.begin() + 0, V.getCoorSchool());
		std::vector<Stop> b = V.getBusAssigned();

		//Set AllCustomer but not depot
		std::vector<Customer> allCustNotDepot;
		for (size_t i = 0; i < V.getBusAssigned().size(); i++) {
			Stop stop = V.getBusAssigned().at(i);
			Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
			allCustNotDepot.insert(allCustNotDepot.begin() + i, customer);
		}
		setAllCustNoDepot(allCustNotDepot);

		a.insert(a.end(), b.begin(), b.end());
		std::vector<Customer> allCustomers;
		for (size_t i = 0; i < a.size(); i++) {
			Stop stop = a.at(i);
			Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
			allCustomers.insert(allCustomers.begin() + i, customer);
		}
		cout << "List of customers! the first customert is the depot." << endl;
		for (size_t i = 0; i < allCustomers.size(); i++) {
			Customer customer = allCustomers.at(i);
			cout << "(" << customer.getX() << ", " << customer.getY() << ", "
					<< customer.getDemand() << ")" << endl;
		}
		setDepot(depot);
		setAllCustomers(allCustomers);
		setK(V.getK());
		setC(V.getCk());
		setKmin(V.getKmin());
	}
	//Validation of the numbers of enters to the depot
	//Initialization of x
	//Initialization of d

	std::vector<Customer> allCustomers = getAllCustomers();
	int nro_customers = getNroCustomers();
	double** d_cvpr = new double*[nro_customers];
	double** s_cvpr = new double*[nro_customers];
	bool** x_cvpr = new bool*[nro_customers];

	for (int i = 0; i < nro_customers; i++) {
		d_cvpr[i] = new double[nro_customers];
		x_cvpr[i] = new bool[nro_customers];
		s_cvpr[i] = new double[nro_customers];
	}
	cout << "Save the distance in a d array of array" << endl;
	for (int i = 0; i < nro_customers; i++) {
		Customer customer = allCustomers.at(i);
		cout << "(" << customer.getX() << ", " << customer.getY() << ")"
				<< endl;
		for (int j = 0; j < nro_customers; j++) {
			Customer pivot = allCustomers.at(j);
			double distance = getDistanceIJ(customer, pivot);
			d_cvpr[i][j] = distance;
			x_cvpr[i][j] = false;
		}
	}
	cout << "Imprimir distance from i to j:" << endl;
	for (int i = 0; i < nro_customers; i++) {
		for (int j = 0; j < nro_customers; j++) {
			cout << d_cvpr[i][j] << " ";
		}
		cout << "\n";
	}

	cout << "Imprimir x from i to j." << endl;
	for (int i = 0; i < nro_customers; i++) {
		for (int j = 0; j < nro_customers; j++) {
			cout << x_cvpr[i][j] << " ";
		}
		cout << "\n";
	}

	setD(d_cvpr);

	//CREATE CONSTRUCTIVE - Saving Computation
	std::vector<Saving> savingList;
	int count1 = 0;
	int nro_buses = getK();
	std::vector<Customer> allCSaving = getAllCustNoDepot();

	for (int i = 0; i < nro_buses; i++) {
		Customer customer = allCSaving.at(i);
		for (int j = 0; j < nro_buses; j++) {
			if (i != j) {
				Customer pivot = allCSaving.at(j);
				double d1 = d_cvpr[i][0];
				double d2 = d_cvpr[0][j];
				double d3 = d_cvpr[i][j];

				s_cvpr[i][j] = d1 + d2 - d3;
				Saving save(customer, pivot, s_cvpr[i][j]);
				savingList.insert(savingList.begin() + count1, save);
				count1++;
			}
		}
	}

	//Ordering
	Saving temp;
	int flag = 1;
	for (size_t i = 1; i < savingList.size() && flag; i++) {
		flag = 0;
		for (size_t j = 0; j < savingList.size() - 1; j++) {
			if (savingList.at(j + 1).getSavingPeso()
					> savingList.at(j).getSavingPeso()) {
				temp = savingList.at(j);
				savingList.at(j) = savingList.at(j + 1);
				savingList.at(j + 1) = temp;
				flag = 1;
			}
		}
	}
	cout << "Saving List after ordered." << endl;
	int m = 0;
	for (size_t i = 0; i < savingList.size(); i++) {
		Saving save = savingList.at(i);
		Customer c1 = save.getSavingC1();
		Customer c2 = save.getSavingC2();
		double peso = save.getSavingPeso();
		cout << "i = (" << c1.getX() << ", " << c1.getY() << ") j = ("
				<< c2.getX() << ", " << c2.getY() << ") peso = " << peso
				<< endl;
	}
	cout << "Insertion." << endl;
	std::vector<std::vector<Customer> > routes;
	for (int i = 0; i < nro_buses; i++) {
		Customer customer = getAllCustNoDepot().at(i);
		//Create routes
		std::vector<Customer> route;
		route.insert(route.begin() + 0, getDepot());
		route.insert(route.begin() + 1, customer);
		route.insert(route.begin() + 2, getDepot());
		routes.insert(routes.begin() + m, route);
		m++;
		route.clear();

	}

	//Routes
	cout << "Print route for each new route:" << endl;
	for (size_t i = 0; i < routes.size(); i++) {
		std::vector<Customer> customers = routes.at(i);
		map.insert(pair<int, std::vector<Customer> >(i, customers));
		cout << "route #" << i << endl;
		for (size_t j = 0; j < customers.size(); j++) {
			Customer c = customers.at(j);
			cout << "(" << c.getX() << ", " << c.getY() << ") - ";
		}
		cout << "\n";
	}

	//Best feasible merge
	//1.- look for 0, j
	/*
	 * Step 2. Best feasible merge (Parallel version)
	 Starting from the top of the savings list, execute the following:
	 Given a saving sij, determine whether there exist two routes that can
	 feasibility be merged:
	 One starting with (0,j)
	 One ending with (i,0)
	 Combine these two routes by deleting (0,j) and (i,0) and introducing (i,j).
	 *
	 */
	cout << "=========================================================="
			<< endl;
	cout << "Starting saving List process" << endl;
	for (size_t i = 0; i < savingList.size(); i++) {
		bool firstCondition = false;
		unsigned int route_number = 0;
		bool secondCondition = false;
		unsigned int route_number2 = 0;

		Saving saving = savingList.at(i);
		Customer customer1 = saving.getSavingC1();
		Customer customer2 = saving.getSavingC2();
		Customer firstElement;
		Customer secondElement;
		cout << "=======Print route each time new SavingList is used========="
				<< endl;
		cout << "For saving customer1 = (" << customer1.getX() << ", "
				<< customer1.getY() << ")" << endl;
		cout << "For saving customer2 = (" << customer2.getX() << ", "
				<< customer2.getY() << ")" << endl;
		for (size_t i = 0; i < routes.size(); i++) {
			std::vector<Customer> customers = routes.at(i);
			cout << "route #" << i << endl;
			for (size_t j = 0; j < customers.size(); j++) {
				Customer c = customers.at(j);
				cout << "(" << c.getX() << ", " << c.getY() << ") - ";
			}
			cout << "\n";
		}

		//First Condition
		for (size_t j = 0; j < routes.size(); j++) {
			std::vector<Customer> customersRoutes = routes.at(j);

			bool c1IsFound = false;
			bool depotIsFound = false;
			unsigned int pivot = 0;

			for (size_t k = 0; k < customersRoutes.size(); k++) {

				Customer c = customersRoutes.at(k);
				if (compareCustomers(c, customer1)) {
					c1IsFound = true;
					pivot = k;
				}
				if (c1IsFound && (pivot + 1 == k)) {
					if (compareCustomers(getDepot(), c)) {
						depotIsFound = true;
						firstElement = customersRoutes.at(pivot);
						cout << "first Element = (" << firstElement.getX()
								<< ", " << firstElement.getY() << ")" << endl;
						route_number = j;
					}
				}
			}
			if (c1IsFound && depotIsFound) {
				map.insert(
						pair<int, std::vector<Customer> >(route_number,
								routes.at(route_number)));
				firstCondition = true;
			} else {
				cout << "Not" << endl;
			}

		}
		//Second condition
		for (size_t j = 0; j < routes.size(); j++) {
			std::vector<Customer> customersRoutes = routes.at(j);
			bool c2IsFound = false;
			bool depot2IsFound = false;
			unsigned int pivot2 = 0;

			for (size_t k = 0; k < customersRoutes.size(); k++) {
				Customer c = customersRoutes.at(k);

				if (compareCustomers(getDepot(), c)) {
					depot2IsFound = true;
					pivot2 = k;
				}
				if (depot2IsFound && (pivot2 + 1 == k)) {
					if (compareCustomers(c, customer2)) {
						c2IsFound = true;
						secondElement = customersRoutes.at(pivot2 + 1);
						cout << "second Element = (" << secondElement.getX()
								<< ", " << secondElement.getY() << ")" << endl;
						route_number2 = j;
					}
				}
			}

			if (depot2IsFound && c2IsFound) {
				map.insert(
						pair<int, std::vector<Customer> >(route_number2,
								routes.at(route_number2)));
				secondCondition = true;
			} else {
				cout << "Not2" << endl;
			}

		}
		if (firstCondition && secondCondition) {
			if (route_number != route_number2) {
				cout << "route 1 = " << route_number << endl;
				cout << "route 2 = " << route_number2 << endl;
				cout << "first Element = (" << firstElement.getX() << ", "
						<< firstElement.getY() << ")" << endl;
				cout << "second Element = (" << secondElement.getX() << ", "
						<< secondElement.getY() << ")" << endl;
				cout << "soy sensacional" << endl;
				std::vector<Customer> route1 = routes.at(route_number);
				for (size_t r = 0; r < route1.size(); r++) {
					Customer c = route1.at(r);
					cout << "(" << c.getX() << ", " << c.getY() << ") -";
				}
				cout << endl;
				//remote the depot
				for (size_t r = 0; r < route1.size(); r++) {
					Customer customer = route1.at(r);
					if (compareCustomers(customer, getDepot())) {
						route1.erase(route1.begin() + r);
					}
				}
				std::vector<Customer> route2 = routes.at(route_number2);
				for (size_t r = 0; r < route2.size(); r++) {
					Customer c = route2.at(r);
					cout << "(" << c.getX() << ", " << c.getY() << ") -";
				}
				cout << endl;
				for (size_t r = 0; r < route2.size(); r++) {
					Customer customer = route2.at(r);
					if (compareCustomers(customer, getDepot())) {
						route2.erase(route2.begin() + r);
					}
				}
				route1.insert(route1.end(), route2.begin(), route2.end());
				cout << "Nueva ruta generada por las rutas " << route_number
						<< " y " << route_number2 << endl;
				for (size_t l = 0; l < route1.size(); l++) {
					Customer customer = route1.at(l);
					cout << "(" << customer.getX() << ", " << customer.getY()
							<< ") - ";
				}
				routes.erase(routes.begin() + route_number);
				routes.erase(routes.begin() + route_number2 - 1);

				cout << "After remove the routes " << route_number << " and "
						<< route_number2 << endl;
				for (size_t i = 0; i < routes.size(); i++) {
					std::vector<Customer> customers = routes.at(i);
					cout << "route #" << i << endl;
					for (size_t j = 0; j < customers.size(); j++) {
						Customer c = customers.at(j);
						cout << "(" << c.getX() << ", " << c.getY() << ") - ";
					}
					cout << "\n";
				}

				routes.push_back(route1);
				cout << "after add the new  route merged." << endl;
				for (size_t i = 0; i < routes.size(); i++) {
					std::vector<Customer> customers = routes.at(i);
					cout << "route #" << i << endl;
					for (size_t j = 0; j < customers.size(); j++) {
						Customer c = customers.at(j);
						cout << "(" << c.getX() << ", " << c.getY() << ") - ";
					}
					cout << "\n";
				}
				cout << "routes.size() = " << routes.size() << endl;

			}
			cout << "=======end saving element from the list=========" << endl;
		} else {
			//Not to merge
		}
	}

	//Route Extension
	//Routes
	cout << "Print routes after the first merge process:" << endl;
	for (size_t i = 0; i < routes.size(); i++) {
		std::vector<Customer> customers = routes.at(i);
		cout << "route #" << i << endl;
		for (size_t j = 0; j < customers.size(); j++) {
			Customer c = customers.at(j);
			cout << "(" << c.getX() << ", " << c.getY() << ") - ";
		}
		cout << "\n";
	}

}
Exemplo n.º 11
0
History::History(Customer cust, Business bus)
{
	customerHistoryID = cust.getID();
}
Exemplo n.º 12
0
bool CVRP::compareCustomers(Customer c1, Customer c2) {
	if ((c1.getX() == c2.getX()) && (c1.getY() == c2.getY())) {
		return true;
	}
	return false;
}
Exemplo n.º 13
0
Customer* Customer::createCustomer(Node* customer_node, struct_MAN* struct_man)
{
	Customer* customer = Customer::create();
	customer->setCustomer(customer_node, struct_man);
	return customer;
}
Exemplo n.º 14
0
// Set the data object from the widgets.
void
CardTransfer::widgetToData()
{
    _gltxFrame->getData(_curr);
    _curr.setMemo(_memo->text());
    _curr.setCardId(_from->getId());
    _quasar->db()->setActive(_curr, !_inactive->isChecked());

    _gltxFrame->getData(_link);
    _link.setNumber(_toNumber->text());
    _link.setShiftId(_toShift->getId());
    _link.setMemo(_memo->text());
    _link.setCardId(_to->getId());
    _quasar->db()->setActive(_link, !_inactive->isChecked());

    fixed amount = _amount->getFixed();
    Id transferAcct = _account->getId();
    Card card;

    Id fromAcct;
    _quasar->db()->lookup(_curr.cardId(), card);
    DataObject::DataType fromType = card.dataType();
    if (card.dataType() == DataObject::CUSTOMER) {
	Customer customer;
	_quasar->db()->lookup(card.id(), customer);
	fromAcct = customer.accountId();
    } else if (card.dataType() == DataObject::VENDOR) {
	Vendor vendor;
	_quasar->db()->lookup(card.id(), vendor);
	fromAcct = vendor.accountId();
    }

    Id toAcct;
    _quasar->db()->lookup(_link.cardId(), card);
    DataObject::DataType toType = card.dataType();
    if (card.dataType() == DataObject::CUSTOMER) {
	Customer customer;
	_quasar->db()->lookup(card.id(), customer);
	toAcct = customer.accountId();
    } else if (card.dataType() == DataObject::VENDOR) {
	Vendor vendor;
	_quasar->db()->lookup(card.id(), vendor);
	toAcct = vendor.accountId();
    }

    // Process fromAcct and transfer acct on first card
    _curr.cards().clear();
    _curr.cards().push_back(CardLine(_curr.cardId(), -amount));
    _curr.accounts().clear();
    if (fromType == DataObject::CUSTOMER) {
        _curr.accounts().push_back(AccountLine(fromAcct, -amount));
        _curr.accounts().push_back(AccountLine(transferAcct, amount));
    } else if (fromType == DataObject::VENDOR) {
        _curr.accounts().push_back(AccountLine(fromAcct, amount));
        _curr.accounts().push_back(AccountLine(transferAcct, -amount));
    }

    // Process toAcct and transfer acct on second card
    _link.cards().clear();
    if (fromType == toType) {
        _link.cards().push_back(CardLine(_link.cardId(), amount));
        _link.accounts().clear();
        if (toType == DataObject::CUSTOMER) {
            _link.accounts().push_back(AccountLine(toAcct, amount));
            _link.accounts().push_back(AccountLine(transferAcct, -amount));
        } else if (toType == DataObject::VENDOR) {
            _link.accounts().push_back(AccountLine(toAcct, -amount));
            _link.accounts().push_back(AccountLine(transferAcct, amount));
       }
    } else {
        _link.cards().push_back(CardLine(_link.cardId(), -amount));
        _link.accounts().clear();
        if (toType == DataObject::CUSTOMER) {
            _link.accounts().push_back(AccountLine(toAcct, -amount));
            _link.accounts().push_back(AccountLine(transferAcct, amount));
        } else if (toType == DataObject::VENDOR) {
            _link.accounts().push_back(AccountLine(toAcct, amount));
            _link.accounts().push_back(AccountLine(transferAcct, -amount));
	}
    }
}
Exemplo n.º 15
0
/** Runs a simple test of the functionality.
  * The integrity of the tree is verified after a number of simple operations:
  *   - insert
  *   - find
  *   - erase
  *   - clear
  */
void functionality_test()
{
  // Validate the empty list
  printlist("Start");

  // Inserting elements
  (new CustomerDefault())->setName("alfa");
  printlist("insert alfa");
  (new CustomerDefault())->setName("beta");
  printlist("insert beta");
  (new CustomerDefault())->setName("alfa1");
  printlist("insert alfa1");
  (new CustomerDefault())->setName("gamma");
  printlist("insert gamma");
  (new CustomerDefault())->setName("delta");
  printlist("insert delta");
  (new CustomerDefault())->setName("omega");
  printlist("insert omega");

  // Searching for some existing names
  string s("delta");
  logger << "Find " << s << ": " << (Customer::find(s) ? "OK" : "NOK") << endl;
  s = "omega";
  logger << "Find " << s << ": " << (Customer::find(s) ? "OK" : "NOK") << endl;

  // Searching for nonexistent name
  s = "hamburger";
  logger << "Find " << s << ": " << (Customer::find(s) ? "OK" : "NOK") << endl;
  printlist("searches");

  // Erasing some existing elements
  delete Customer::find("delta");
  printlist("erase delta");
  delete Customer::find("gamma");
  printlist("erase gamma");

  // Erasing some existing elements
  delete Customer::find("hamburger");
  printlist("erase hamburger");

  // Inserting a duplicate
  (new CustomerDefault())->setName("alfa2");
  printlist("insert alfa2");
  (new CustomerDefault())->setName("alfa4");
  printlist("insert alfa4");
  (new CustomerDefault())->setName("alfa x");
  printlist("insert alfa x");
  (new CustomerDefault())->setName("alfa y");
  printlist("insert alfa y");
  (new CustomerDefault())->setName("alfa z");
  printlist("insert alfa z");
  (new CustomerDefault())->setName("delta");
  printlist("insert delta");
  (new CustomerDefault())->setName("phi");
  printlist("insert phi");

  // Inserting an already existing element
  Customer * k = new CustomerDefault();
  k->setName("alfa2");
  logger << k->getName() << endl;
  printlist("duplicate insert alfa2");
  delete k;

  // Clearing the list
  Customer::clear();
  printlist("clear");
}
Exemplo n.º 16
0
	bool operator()(const Customer& cust) const
	{
		return code == cust.Code();
	}
Exemplo n.º 17
0
    void run()
    {
        int period_index = 0; // 0 a 6
        // Use util->max/minPeopleFlow
        int minFlow = util->minPeopleFlow[period_index];
        int maxFlow = util->maxPeopleFlow[period_index];
        cout << "NEW FLOW IS FROM " << minFlow << " TO " << maxFlow <<endl;

        int timeNextCustomer = util->getRand(minFlow, maxFlow);
        cout <<"First curstomer arrives in " << util->getMinute(timeNextCustomer) << "min and " << util->getSeconds(timeNextCustomer)<< " seconds" << endl;

        while(util->time <= 24 * 3600)
        {
            this->changePeriod(period_index, minFlow, maxFlow);




            int rand = util->getRand(util->minTimeAtCashier, util->maxTimeAtCachier);

            // CHECK ARRIVING CUSTOMER
            if(timeNextCustomer == 0)
            {
                // NEW CUSTOMER ARRIVE AT THE TIME CURRENT
                cout << "New Customer Arrived at "<< util->getHour(util->time) << ":" <<util->getMinute(util->time) <<"!" << endl;
                Customer *customer = new Customer(util->time);

                if (cashierList->getSize() == 0) // First cashier
                {
                    Cashier *cashier = new Cashier();
                    this->cashierList->insert(cashier);
                    cashier->customersLine->insert(customer);
                    cout << "Openning the first cashier!" << endl;
                }
                else
                {
                    // VERIFY CASHIERS AND PROCESS CUSTOMERS WAIT
                    Node<Cashier*> *node = this->cashierList->getFirst();
                    int listSize = this->cashierList->getSize();
                    for(int i=0; i<= listSize && node!=NULL; i++)
                    {
                        Cashier *cashier = node->getValue();
                        cashier->processCashier(rand);
                        if (cashier->customersLine->getSize()>0)
                        {
                            Customer *firstCustomer = cashier->getFirstCustomer();
                            int leftCustomerWaitTime = util->maxWaitLine - firstCustomer->getWaitingTime(util->time);

                            // ATTENTION!!! CUSTOMER WAITING ALERT!
                            if (cashier->busyTime > leftCustomerWaitTime) // NOT ENOUGH TIME
                            {
                                Cashier *available = getAvailableCashier(leftCustomerWaitTime);

                                if (available != NULL)
                                {
                                    available->customersLine->insert(firstCustomer);
                                }
                                else
                                {
                                    // NO OTHER CASHIER AVAILABLE
                                    Cashier *newCashier = new Cashier();
                                    newCashier->customersLine->insert(firstCustomer);
                                    cashier->customersLine->remove(firstCustomer);
                                    rand = util->getRand(util->minTimeAtCashier, util->maxTimeAtCachier);
                                    newCashier->processCashier(rand);
                                    this->cashierList->insert(newCashier);
                                    cout << "Openning an emergencial cashier! Customer waiting for more than " << util->getMinute(firstCustomer->getWaitingTime(util->time)) << " min"  << endl;
                                }
                            }
                        }

                        node = node->getNext();
                    } // End for


                    // ADD NEW CUSTOMER
                    node = this->cashierList->getFirst();
                    int minLine = 1000000, index = 0;
                    for(int i=0; i<= this->cashierList->getSize() && node!=NULL; i++)
                    {
                        Cashier *cashier = node->getValue();
                        if(cashier->getLineSize() < minLine)
                        {
                            minLine = cashier->getLineSize();
                            index = i;
                        }
                        node = node->getNext();
                    } // End for
                    LinkedList<Cashier*> *list = this->cashierList;
                    Cashier *cashier = list->getValueAt(index);
                    LinkedList<Customer*> *list1 = cashier->customersLine;
                    list1->insert(customer);
                } // END ELSE LIST NOT EMPTY

                // PREPARE NEXT CUSTOMER ARRIVING
                timeNextCustomer = util->getRand(minFlow, maxFlow);
                cout <<"Next curstomer arrives in " << util->getMinute(timeNextCustomer) << "min and " << util->getSeconds(timeNextCustomer)<< " seconds"<<endl;

            } // END CHECK ARRIVING CUSTOMER
            else
            {
                    Node<Cashier*> *node = this->cashierList->getFirst();
                    int i = 0;
                    while(node != NULL)
                    {
                        Cashier *cashier = node->getValue();
                        i++;
                        if (cashier->processCashier(rand))
                        {
                            cout << "Cashier " << i << " is available for next Customer"<<endl;
                            printStatus();
                        };
                        node = node->getNext();
                    } // End

            }


            // CHECK CURRENT CUSTOMERS STATUS

            if (util->time% (300 / (period_index+1)) == 0 ){
                printStatus();
                cout << endl;
                system("pause");
                getchar();
                cout << endl;

            }




            util->passTime();
            timeNextCustomer--;
        } // END TIME ITERATIONS

        // DISPLAY RESULTS
           for(int j = 0; j < 7; j++)
           {
                cout << "Starting at " << util->period[j] <<"h " << ": " << util->maxCashiers[j] <<endl;
           }
    } // END RUN()
bool Customer::operator <(const Customer& otherCustomer) const
{
    return this->getUserName() < otherCustomer.getUserName();
}
Exemplo n.º 19
0
int main(int argc, char* argv[])
{
  BookStore myBookStore(&cout, &cerr);
  fstream inventoryFile;
  fstream customerFile;
  fstream transactionFile;
  char line[MAX_LINE_SIZE];

  if (argc != 4)
  {
    cerr << "Usage: " << argv[0] << " InventoryFilename CustomerFileName TransactionsFilename" << endl;
    return -1;
  }

  ///////////////////////////
  /////READ IN INVENTORY/////
  ///////////////////////////
  inventoryFile.open(argv[1]);
  if (!inventoryFile.is_open())
  {
    cerr << "Inventory File not found" << endl;
    return -1;
  }

  while (inventoryFile.getline(line, MAX_LINE_SIZE))
  {
    stringstream ss;
    char token[MAX_TITLE];
    char bookType, newUsedType;
    int copies;
    string author, title;
    float cost;

    ss << line;
    ss.getline(token, MAX_TITLE, ',');
    bookType = token[0];
    ss.getline(token, MAX_TITLE, ',');
    newUsedType = token[0];
    ss.getline(token, MAX_TITLE, ',');
    copies = atof(token);
    ss.getline(token, MAX_TITLE, ',');
    author = (string)token;
    ss.getline(token, MAX_TITLE, ',');
    title = (string)token;
    ss.getline(token, MAX_TITLE, ',');
    cost = atof(token);

    switch (bookType)
    {
      case 'B':
      {
        if (newUsedType != 'N')
        {
          ss.getline(token, MAX_TITLE, ',');
          newUsedType = token[0];
        }
        string quality = string(1, newUsedType);

        Book* insBook = new Book(author, title, cost, quality);
        myBookStore.AddBook(insBook, copies);
        break;
      }
      case 'A':
      {
        string narrator;
        ss.getline(token, MAX_TITLE, ',');
        narrator = (string)token;

        if (newUsedType != 'N')
        {
          ss.getline(token, MAX_TITLE, ',');
          newUsedType = token[0];
        }
        string quality = string(1, newUsedType);

        AudioBook* insABook = new AudioBook(author, title, cost, narrator, quality);
        Book* insBook = insABook;
        myBookStore.AddBook(insBook, copies);
        break;
      }
      case 'G':
      {
        string artist;
        ss.getline(token, MAX_TITLE, ',');
        artist = (string)token;

        if (newUsedType != 'N')
        {
          ss.getline(token, MAX_TITLE, ',');
          newUsedType = token[0];
        }
        string quality = string(1, newUsedType);

        GraphicNovel* insGNBook = new GraphicNovel(author, title, cost, artist, quality);
        Book* insBook = insGNBook;
        myBookStore.AddBook(insBook, copies);
        break;
      }
      default:
      {
        cerr << "ERROR. Invalid Entry" << endl;
      }
    }
  }

  ///////////////////////////
  /////READ IN CUSTOMERS/////
  ///////////////////////////
  customerFile.open(argv[2]);
  if (!customerFile.is_open())
  {
    cerr << "Customer File not found" << endl;
    return -1;
  }

  while (customerFile.getline(line, MAX_LINE_SIZE))
  {
    stringstream ss;
    char token[MAX_TITLE];
    string firstName, lastName;
    int age;

    ss << line;
    ss.getline(token, MAX_TITLE, ',');
    firstName = (string)token;
    ss.getline(token, MAX_TITLE, ',');
    lastName = (string)token;
    ss.getline(token, MAX_TITLE, ',');
    age = atoi(token);

    if (age > 65) {
      SeniorCustomer* insCustomer = new SeniorCustomer(firstName, lastName, age);
      myBookStore.AddCustomer(insCustomer);
    }
    else
    {
      Customer* insCustomer = new Customer(firstName, lastName, age);
      myBookStore.AddCustomer(insCustomer);
    }
  }


  ////////////////////////////////////////
  /////READ IN + PROCESS TRANSACTIONS/////
  ////////////////////////////////////////
  transactionFile.open(argv[3]);
  if (!transactionFile.is_open())
  {
    cerr << "File not found" << endl;
    return -1;
  }

  while (transactionFile.getline(line, MAX_LINE_SIZE))
  {
    stringstream ss;
    char token[MAX_TITLE];
    char transType;

    ss << line;
    ss.getline(token, MAX_TITLE, ',');
    transType = token[0];


    switch (transType)
    {
      case 'I':
      {
        myBookStore.PrintInventory();
        break;
      }
      case 'H':
      {
        string custFirstName, custLastName;
        Customer myCustomer;

        ss.getline(token, MAX_TITLE, ',');
        custFirstName = (string)token;
        myCustomer.setFirstName(custFirstName);
        ss.getline(token, MAX_TITLE, ',');
        custLastName = (string)token;
        custLastName = rtrim(custLastName);
        myCustomer.setLastName(custLastName);

        myBookStore.PrintCustomerHistory(myCustomer);
        break;
      }
      case 'P':
      {
        string custFirstName, custLastName;
        Customer myCustomer;
        char bookType, newUsedType;
        string author, title;

        ss.getline(token, MAX_TITLE, ',');
        custFirstName = (string)token;
        myCustomer.setFirstName(custFirstName);
        ss.getline(token, MAX_TITLE, ',');
        custLastName = (string)token;
        myCustomer.setLastName(custLastName);

        ss.getline(token, MAX_TITLE, ',');
        bookType = token[0];
        ss.getline(token, MAX_TITLE, ',');
        newUsedType = token[0];
        ss.getline(token, MAX_TITLE, ',');
        author = (string)token;
        ss.getline(token, MAX_TITLE, ',');
        title = (string)token;
        title = rtrim(title);

        switch (bookType)
        {
          case 'B':
          {
            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            Book* myBook = new Book(author, title);
            myBook->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessPurchase(myCustomer, myBook);
            break;
          }
          case 'A':
          {
            string narrator;
            ss.getline(token, MAX_TITLE, ',');
            narrator = (string)token;

            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            AudioBook* myAudioBook = new AudioBook(author, title);
            myAudioBook->setNarrator(narrator);
            myAudioBook->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessPurchase(myCustomer, myAudioBook);
            break;
          }
          case 'G':
          {
            string artist;
            ss.getline(token, MAX_TITLE, ',');
            artist = (string)token;

            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            GraphicNovel* myGraphicNovel = new GraphicNovel(author, title);
            myGraphicNovel->setArtist(artist);
            myGraphicNovel->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessPurchase(myCustomer, myGraphicNovel);
            break;
          }
          default:
          {
            cerr << "ERROR. Invalid Entry" << endl;
          }
        }
        break;
      }
      case 'R':
      {
        string custFirstName, custLastName;
        Customer myCustomer;
        char bookType, newUsedType;
        string author, title;

        ss.getline(token, MAX_TITLE, ',');
        custFirstName = (string)token;
        myCustomer.setFirstName(custFirstName);
        ss.getline(token, MAX_TITLE, ',');
        custLastName = (string)token;
        myCustomer.setLastName(custLastName);

        ss.getline(token, MAX_TITLE, ',');
        bookType = token[0];
        ss.getline(token, MAX_TITLE, ',');
        newUsedType = token[0];
        ss.getline(token, MAX_TITLE, ',');
        author = (string)token;
        ss.getline(token, MAX_TITLE, ',');
        title = (string)token;
        title = rtrim(title);

        switch (bookType)
        {
          case 'B':
          {
            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            Book* myBook = new Book(author, title);
            myBook->setQuality(quality);
            Book* myCopiedBook = new Book(author, title);
            myCopiedBook->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessReturn(myCustomer, myBook, myCopiedBook);
            break;
          }
          case 'A':
          {
            string narrator;
            ss.getline(token, MAX_TITLE, ',');
            narrator = (string)token;

            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            AudioBook* myAudioBook = new AudioBook(author, title);
            myAudioBook->setNarrator(narrator);
            myAudioBook->setQuality(quality);
            AudioBook* myCopiedAudioBook = new AudioBook(author, title);
            myCopiedAudioBook->setNarrator(narrator);
            myCopiedAudioBook->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessReturn(myCustomer, myAudioBook, myCopiedAudioBook);
            break;
          }
          case 'G':
          {
            string artist;
            ss.getline(token, MAX_TITLE, ',');
            artist = (string)token;

            if (newUsedType != 'N')
            {
              ss.getline(token, MAX_TITLE, ',');
              newUsedType = token[0];
            }
            string quality = string(1, newUsedType);

            GraphicNovel* myGraphicNovel = new GraphicNovel(author, title);
            myGraphicNovel->setArtist(artist);
            myGraphicNovel->setQuality(quality);
            GraphicNovel* myCopiedGraphicNovel = new GraphicNovel(author, title);
            myCopiedGraphicNovel->setArtist(artist);
            myCopiedGraphicNovel->setQuality(quality);

            //Do Stuff with myBook
            myBookStore.ProcessReturn(myCustomer, myGraphicNovel, myCopiedGraphicNovel);
            break;
          }
          default:
          {
            cerr << "ERROR. Invalid Entry" << endl;
          }
        }
        break;
      }
      case 'T':
      {
        string custFirstName, custLastName;
        Customer myCustomer;
        char bookType, newUsedType;
        string author, title;
        float cost;

        ss.getline(token, MAX_TITLE, ',');
        custFirstName = (string)token;
        myCustomer.setFirstName(custFirstName);
        ss.getline(token, MAX_TITLE, ',');
        custLastName = (string)token;
        myCustomer.setLastName(custLastName);

        ss.getline(token, MAX_TITLE, ',');
        bookType = token[0];
        ss.getline(token, MAX_TITLE, ',');
        author = (string)token;
        ss.getline(token, MAX_TITLE, ',');
        title = (string)token;
        ss.getline(token, MAX_TITLE, ',');
        cost = atof(token);

        switch (bookType)
        {
          case 'B':
          {
            ss.getline(token, MAX_TITLE, ',');
            newUsedType = token[0];
            string quality = string(1, newUsedType);

            Book* myBook = new Book(author, title, cost, quality);
            Book* myCopiedBook = new Book(author, title, cost, quality);

            //Do Stuff with myBook
            myBookStore.ProcessTradeIn(myCustomer, myBook, myCopiedBook);
            break;
          }
          case 'A':
          {
            string narrator;
            ss.getline(token, MAX_TITLE, ',');
            narrator = (string)token;

            ss.getline(token, MAX_TITLE, ',');
            newUsedType = token[0];
            string quality = string(1, newUsedType);

            AudioBook* myAudioBook = new AudioBook(author, title, cost, narrator, quality);
            AudioBook* myCopiedAudioBook = new AudioBook(author, title, cost, narrator, quality);

            //Do Stuff with myBook
            myBookStore.ProcessTradeIn(myCustomer, myAudioBook, myCopiedAudioBook);
            break;
          }
          case 'G':
          {
            string artist;
            ss.getline(token, MAX_TITLE, ',');
            artist = (string)token;

            ss.getline(token, MAX_TITLE, ',');
            newUsedType = token[0];
            string quality = string(1, newUsedType);

            GraphicNovel* myGraphicNovel = new GraphicNovel(author, title, cost, artist, quality);
            GraphicNovel* myCopiedGraphicNovel = new GraphicNovel(author, title, cost, artist, quality);

            //Do Stuff with myBook
            myBookStore.ProcessTradeIn(myCustomer, myGraphicNovel, myCopiedGraphicNovel);
            break;
          }
          default:
          {
            cerr << "ERROR. Invalid Entry" << endl;
          }
        }
        break;
      }
      default:
      {
        cerr << "ERROR. Invalid Transaction Entry" << endl;
      }
    }
  }

  cout << myBookStore.getBalance();
  return 0;
}
Exemplo n.º 20
0
bool Simulator::startSimulation() {
	srand(time(NULL));
	double enq_time = 0;
	int cus_id = 1;
	int ev_id = 1;
	for (int i = 1; i<= 5; i++) {
			
		enq_time += cusTimeMin + (double)(fmod((double)rand(),(double)(10000*(cusTimeMax - cusTimeMin + 1))))/10000.0;	
		
		Customer* newCus = new Customer(cus_id, "", enq_time, floors, sane);
		Event newEvent(ev_id, "", CUST_CALL, newCus->getDir(), newCus->getAt(), enq_time, newCus);
		system.upcomingEvents.push(newEvent);
		
		if (DEBUG_SIM) {	// The DEBUG flag
			cout<<"Setting up Customer "<<cus_id<<" to arrive at floor "<<newCus->getAt()<<" at time = "<<enq_time<<endl;
			}
		
		cus_id++;
		ev_id++;
		}
	
	while (departed < cusToSimulate) {
		
		while (enq_time - system.upcomingEvents.getMinTime() < cusTimeMax) {
			enq_time += cusTimeMin + (double)(fmod((double)rand(),(double)(10000*(cusTimeMax - cusTimeMin + 1))))/10000.0;	
		
		Customer* newCus = new Customer(cus_id, "", enq_time, floors, sane);
		Event newEvent(ev_id, "", CUST_CALL, newCus->getDir(), newCus->getAt(), enq_time, newCus);
		system.upcomingEvents.push(newEvent);
		
		if (DEBUG_SIM) {	// The DEBUG flag
			cout<<"Setting up Customer "<<cus_id<<" to arrive at floor "<<newCus->getAt()<<" at time = "<<enq_time<<endl;
			}
			
		cus_id++;
		ev_id++;
		}
		
		Event to_process = system.upcomingEvents.pop();
		
		if (DEBUG_SIM) {	// The DEBUG flag
			cout<<"Processing Event-id "<<to_process.getId()<<" with timestamp "<<to_process.getTime()<<endl;
			}
		clock.updateTick(to_process.getTime());
		to_process.process();
		system.update(clock);
		
		if (DEBUG_SIM) {	// The DEBUG flag
			cout<<"Clock Updated"<<endl;
			}
		
		Event new_event;
		new_event = system.giveEvent(to_process);
		if (DEBUG_SIM) {	// The DEBUG flag
			cout<<"Event Given"<<endl;
			}

		if (to_process.getType() == ENTER) {
			Event go_evnt(ev_id, "", CUST_GO, DEFAULT, to_process.getCustomer()->getTo(), to_process.getTime(), to_process.getCustomer(), to_process.getElevator());
			go_evnt.process();
			new_event = system.giveEvent(go_evnt);
			ev_id++;
			}
		if (new_event.getType() != DEFAULT) {
			if (DEBUG_SIM) cout<<"Pushing Event "<<new_event.getType()<<endl; // The DEBUG flag
			system.upcomingEvents.push(new_event);
			}
		if (to_process.getType()==LEAVE) {
			if (DEBUG_SIM) cout<<"Leave Event "<<endl; // The DEBUG flag
			departed++;
			}
		}
		system.printMetrics();
	}
Exemplo n.º 21
0
int main()
{
    Bank bank1; //this bank uses linked lists for its customers and accounts.
    
    cout << "--BANK DATABASE IMPLEMENTED USING LINKED LISTS--" << endl << endl;
    
    //CUSTOMER LINKED LIST
    
    ifstream in1;
    in1.open("customers0.txt");
    if (in1.fail())
    {
        cout << "unable to open customers0.txt" << endl;
        return 0;
    }
    while (!in1.eof())
    {
        Customer *newCustomer = new Customer();
        in1 >> (newCustomer -> customerID) >> (newCustomer -> lastName);
        in1 >> (newCustomer -> firstName) >> (newCustomer -> address);
        
        bank1.addCustomer(newCustomer);
    }
    in1.close();
    
    int totalcustomers = bank1.getccurrentlyInList();
    
    cout << "Total number of customers: " << totalcustomers << endl;
    
    
    //ACCOUNT LINKED LIST
    
    
    ifstream in2;
    in2.open("accounts0.txt");
    if (in2.fail())
    {
        cout << "unable to open accounts0.txt" << endl;
        return 0;
    }
    while (!in2.eof())
    {
        Account *newAccount = new Account();
        in2 >> (newAccount -> accountID) >> (newAccount -> customerID);
        in2 >> (newAccount -> balance);
        
        bank1.addAccount(newAccount);
    }
    in2.close();
    
    int totalaccounts = bank1.getacurrentlyInList();
    
    cout << "Total number of accounts: " << totalaccounts << endl;
    
    int totalbalance = bank1.getTotalAccountsBalance();
    
    cout << "Total Accounts Balance: " << totalbalance << " cents" << endl;
    
    int customerIDSearch;
    cout << "Enter Customer ID: ";
    cin >> customerIDSearch;
    bank1.search(customerIDSearch); //this search function calls the printCustomer() function within it.
    int numberOfComparisons = bank1.getNumberOfComparisonsLL();
    cout << "Number of Comparisons made (linked list): " << numberOfComparisons << endl;
    
    //----------------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------------
    
    
    Bank bank2; //this bank uses binary search trees for its customers and accounts.
    
    cout << endl << "--BANK DATABASE IMPLEMENTED USING BINARY SEARCH TREES--" << endl << endl;
    
    //CUSTOMER BINARY SEARCH TREE
    
    ifstream in3;
    in3.open("customers0.txt");
    if (in3.fail())
    {
        cout << "unable to open customers0.txt" << endl;
        return 0;
    }
    while (!in3.eof())
    {
        Customer *newCustomer = new Customer();
        in3 >> (newCustomer -> customerID) >> (newCustomer -> lastName);
        in3 >> (newCustomer -> firstName) >> (newCustomer -> address);
        
        
            //The following two lines of code prints out the details of every customer added (used for debugging purposes)
        
            //cout << newCustomer->customerID << " " << newCustomer->lastName << " ";
            //cout << newCustomer->firstName << " " <<newCustomer->address << endl;
        
        bank2.addCustomerBST(newCustomer);
    }
    in3.close();
    
    totalcustomers = bank2.getccurrentlyInList();
    
    cout << "Total number of customers: " << totalcustomers << endl;
    
    
    //ACCOUNT BINARY SEARCH TREE
    
    
    ifstream in4;
    in4.open("accounts0.txt");
    if (in4.fail())
    {
        cout << "unable to open accounts0.txt" << endl;
        return 0;
    }
    while (!in4.eof())
    {
        Account *newAccount = new Account();
        in4 >> (newAccount -> accountID) >> (newAccount -> customerID);
        in4 >> (newAccount -> balance);
        
        bank2.addAccountBST(newAccount);
    }
    in4.close();
    
    totalaccounts = bank2.getacurrentlyInList();
    
    cout << "Total number of accounts: " << totalaccounts << endl;
    
    totalbalance = bank2.getTotalAccountsBalance();
    
    cout << "Total Accounts Balance: " << totalbalance << " cents" << endl;
    
    
    cout << "Enter Customer ID: ";
    cin >> customerIDSearch;
    Customer *search = bank2.publicSearchCustomer(customerIDSearch);
    if ((bank2.publicSearchCustomer(customerIDSearch)) == NULL)
    {
        cout << "ERROR: Invalid Customer ID." << endl;
    }
    else
    {
        search->printCustomer();
    }
    numberOfComparisons = bank2.getNumberOfComparisonsBST();
    cout << "Number of Comparisons made (binary search trees): " << numberOfComparisons << endl;
    
    return 0;
}
Exemplo n.º 22
0
/** 
 * Injects customers into the network using forward.
 * The initial location of the customer is the source node.
 */
void Source::injectCustomer() {
	Customer *c =  buildCustomer() ;
	c->setLocation( this ) ;
	forward( c ) ;
}
Exemplo n.º 23
0
//-----------------------------------------------------------------------------
// processTransactions(ifstream& infile) const
// Process a list of transactions from an input file
//-----------------------------------------------------------------------------
void MovieStore::processTransactions(ifstream& infile)
{
    while (true)
    {
        if (infile.eof() || !infile.good())
        {
            break;
        }

        char c;
        infile >> c;
        string key;
        stringstream ss;
        Customer target;

        switch (c)
        {
            // borrow and return
            case 'B':
            case 'R':
                int custId;
                char format;
                char genre;
                char sz[256];
                Customer* pCust;
                Movie* pMovie;

                infile >> custId >> format >> genre;
                infile.get();
                infile.get(sz, ARRAYSIZE(sz));
                key = sz;

                ss << custId;
                target.setKey(ss.str());

                // Clean up
                infile.clear();
                infile.ignore(numeric_limits<streamsize>::max(), '\n');

                // Validate genre
                if (!m_movieManager.isValidGenre(genre))
                {
                    cerr << "Invalid genre '" << genre << "'" << endl;
                    continue;
                }

                // Retrieve customer
                pCust = dynamic_cast<Customer*>(m_customersHash.retrieve(target));

                // Retrieve movie
                pMovie = m_movieManager.find(genre, key);

                // Validate customer
                if (NULL == pCust)
                {
                    cerr << "Customer '" << custId << "' not found" << endl;
                    continue;
                }
                // Validate movie
                else if (NULL == pMovie)
                {
                    cerr << "Movie with key '" << key << "' not found" << endl;
                    continue;
                }
                // Validate checkout
                else if (! toggleCheckoutState(('B' == c), pMovie, custId, format))
                {
                    continue;
                }
                else
                {
                    // Add transaction record to customer
                    Transaction* pTrans = new Transaction(pMovie, c, format);
                    pCust->addTransaction(pTrans);
                }

                break;

            // show movie inventory
            case 'S':
                m_movieManager.print();
                break;

            // Display transaction history by customer
            case 'H':
                cout << m_customers;
                break;

            default:
                cout << "Invalid transaction code " << c << endl;

                // Clean up
                infile.clear();
                infile.ignore(numeric_limits<streamsize>::max(), '\n');

                break;
        }
    }
}
Exemplo n.º 24
0
void purchaseItem(vector<items> & vectorOfItems, Customer & user) {
	int count = 0;
	int index;
	string input;
	string temp;
	cout << "Enter the name of the item: " << endl;
	getline(cin, temp);
	getline(cin, input);
	for (unsigned int i = 0; i < input.length(); i++)
	{
		input[i] = tolower(input[i]);
	}
	bool isInStock = false;
	for (size_t i = 0; i < vectorOfItems.size(); i++)
	{
		if (vectorOfItems[i].getItemName() == input) {
			isInStock = true;
			index = i;
			count++;
		}
	}
	if (!isInStock) {
		cout << "Sorry, that item is not in stock" << endl;
	}
	else {
		cout << "We have " << count << " " << input << "(s) in stock for " << vectorOfItems[index].getItemPrice() << " each. Continue with purchase?" << endl;
		cout << "1. Yes" << endl;
		cout << "2. No" << endl;
		string optionS;
		int option = 0;
		getline(cin, optionS);
		option = atoi(optionS.c_str());
		while (!isNumber(optionS) || (option != 1 && option != 2))
		{
			cout << "Not a valid choice. Please enter 1 or 2." << endl;
			getline(cin, optionS);
			if (isNumber(optionS))
			{
				option = atoi(optionS.c_str());
			}
		}
		if (option == 1)
		{
			int amt = -1;
			cout << "How many would you like to purchase?" << endl;
			getline(cin, optionS);
			amt = atoi(optionS.c_str());
			int num = 0;
			while ((!isNumber(optionS)) || (amt < 1) || (amt > count))
			{
				cout << "Not a valid choice. Please enter a number between 1 and " << count << "." << endl;
				getline(cin, optionS);
				if (isNumber(optionS))
				{
					amt = atoi(optionS.c_str());
				}
			}
			for (size_t i = 0; i < vectorOfItems.size(); i++)
			{
				if (input == vectorOfItems[i].getItemName())
				{
					if (user.noMoreMoney(vectorOfItems[i].getItemPrice()))
					{
						cout << "You have no more money left!" << endl;
						break;
					}
					else
					{
						user.subtractBudget(vectorOfItems[i].getItemPrice());
						num += 1;
						vectorOfItems.erase(vectorOfItems.begin() + i);
						i--;
						amt--;
						if (amt == 0)
							i = vectorOfItems.size();
					}
				}
			}
			cout << "Congratulations, you purchased  " << num << " " << input << "(s)!" << endl;
		}
		else if (option == 2)
		{
		}
		else
		{
			cout << "Invalid choice. Purchase?" << endl;
			cout << "1. Yes" << endl;
			cout << "2. No" << endl;
		}
	}
}
Exemplo n.º 25
0
void
ServiceCharges::slotPost()
{
    QDate end = _end->getDate();
    Id store_id = _store->getId();
    Id account_id = _account->getId();

    // Validate data
    if (store_id == INVALID_ID) {
	QString message = tr("A store must be entered");
	QMessageBox::critical(this, tr("Error"), message);
	_store->setFocus();
	return;
    }
    if (account_id == INVALID_ID) {
	QString message = tr("An account must be entered");
	QMessageBox::critical(this, tr("Error"), message);
	_account->setFocus();
	return;
    }

    QString message = tr("Are you sure you want to post the charges?");
    int ch = QMessageBox::warning(this, tr("Continue?"), message,
				  QMessageBox::No, QMessageBox::Yes);
    if (ch != QMessageBox::Yes) return;

    QApplication::setOverrideCursor(waitCursor);
    qApp->processEvents();

    QListViewItemIterator it(_charges);
    for (; it.current(); ++it) {
	ListViewItem* item = (ListViewItem*)it.current();
	Id customer_id = item->id;
	fixed amount = item->value(1).toFixed();
	if (customer_id == INVALID_ID) continue;

	Customer customer;
	_quasar->db()->lookup(customer_id, customer);

	// Generate service charge transaction
	CardAdjust adjustment;
	adjustment.setPostDate(end);
	adjustment.setPostTime(QTime(0, 0, 0));
	adjustment.setMemo(tr("Service Charges"));
	adjustment.setCardId(customer_id);
	adjustment.setStoreId(store_id);

	CardLine cardLine(customer_id, amount);
	adjustment.cards().push_back(cardLine);

	// Add account lines
	Id receivables_id = customer.accountId();
	adjustment.accounts().push_back(AccountLine(receivables_id, amount));
	adjustment.accounts().push_back(AccountLine(account_id, -amount));

	// Post adjustment
	_quasar->db()->create(adjustment);
    }

    Company orig, company;
    _quasar->db()->lookup(orig);
    company = orig;

    company.setLastServiceCharge(end);
    company.setChargeAccount(account_id);
    _quasar->db()->update(orig, company);

    QApplication::restoreOverrideCursor();
    message = tr("The service charges have been posted");
    QMessageBox::information(this, tr("Posted"), message);

    close();
}
Exemplo n.º 26
0
//method that generates a questionnaire for the customer to fill out.
void recGift(vector<items> & vectorOfItems, vector<items> & recommendedItems, Customer & user) {
	string userchoice = "";
	int userpref = 0;
	int creativity = 0;
	int activity = 0;
	int complexity = 0;
	string tempchoice = "";
	recommendedItems.clear();
	cout << "Please answer the following questions with either a 1 or 2 so we can match you to your perfect item" << endl;
	cout << endl << "Would you rather 1. paint a picture or 2. ride a bike?" << endl;
	getline(cin, tempchoice);

	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		creativity += 3;
		activity -= 1;
	}
	else if (userpref == 2) {
		activity += 3;
	}
	cout << endl << "Can you solve a Rubiks Cube? 1. yes 2. no" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << endl << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		complexity += 2;
	}
	else if (userpref == 2) {
		complexity -= 1;
	}
	cout << endl << "Have you ever watched a Marvel movie? 1. yes 2. no " << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		creativity += 1;
	}
	cout << endl << "Can you see yourself skydiving? 1. yes 2. no" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		activity += 3;
	}
	cout << endl << "Is your spirit animal moreso 1. a cheetah or 2. a sloth" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		activity += 2;
	}
	else if (userpref == 2) {
		activity -= 2;
	}
	cout << endl << "Do you believe in aliens? 1. yes 2. no" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		creativity += 2;
		complexity += 1;
	}
	cout << endl << "Can you do a backflip? 1. yes 2. no" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		activity += 4;
	}
	cout << endl << "1. Super Smash or 2. volleyball?" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		creativity += 2;
		activity -= 1;
	}
	else if (userpref == 2) {
		activity += 2;
	}
	cout << endl << "Would you rather 1. become a sentient strawberry with the mind you have now (cannot communicate or have mobility) or 2. just become a regular strawberry with strawberry thoughts?" << endl;
	userpref = 0;
	getline(cin, userchoice);
	userpref = atoi(userchoice.c_str());
	while (!isNumber(userchoice) || (userpref != 1 && userpref != 2))
	{
		cout << "Not a valid choice. Please enter 1 or 2." << endl;
		getline(cin, userchoice);
		if (isNumber(userchoice))
		{
			userpref = atoi(userchoice.c_str());
		}
	}
	if (userpref == 1) {
		creativity += 1;
		activity += 1;
	}
	else if (userpref == 2) {
		activity -= 2;
	}

	if (complexity > 5) {
		complexity = 5;
	}
	if (creativity > 5) {
		creativity = 5;
	}
	if (activity > 5) {
		activity = 5;
	}
	if (complexity < 0) {
		complexity = 0;
	}
	if (creativity < 0) {
		creativity = 0;
	}
	if (activity < 0) {
		activity = 0;
	}

	bestFitItem(recommendedItems, vectorOfItems, creativity, activity, complexity);
	cout << endl << "The following are your survey results:" << endl;
	cout << "Activity: " << activity << endl;
	cout << "Creativity: " << creativity << endl;
	cout << "Complexity: " << complexity << endl;
	cout << "The following items are recommended for you:" << endl;
	for (size_t i = 0; i < recommendedItems.size(); i++) {
		cout << "Item: " << recommendedItems[i].getItemName() << endl;
		cout << "\tPrice: $" << recommendedItems[i].getItemPrice() << endl;
		if (user.noMoreMoney(recommendedItems[i].getItemPrice())) {
			cout << "\tWarning! This item is over your budget!" << endl;
		}
	}
	cout << endl;
}	
Exemplo n.º 27
0
void task_06() // let it be kind a main func
{
	// setting things up
	std::srand(std::time(0)); // random initializing of rand()
	cout << "Case Study: Bank of Heather Automatic Teller\n";
	cout << "Enter maximum size of queue: ";
	int qs;
	cin >> qs;
	queue<Customer> line; // line queue holds up to qs people
	cout << "Enter the number of simulation hours: ";
	int hours; // hours of simulation
	cin >> hours;
	// simulation will run 1 cycle per minute
	long cyclelimit = MIN_PER_HR * hours; // # of cycles
	cout << "Enter the average number of customers per hour: ";
	double perhour; // average # of arrival per hour
	cin >> perhour;
	double min_per_cust; // average time between arrivals
	min_per_cust = MIN_PER_HR / perhour;
	Customer temp; // new customer data
	long turnaways = 0; // turned away by full queue
	long customers = 0; // joined the queue
	long served = 0; // served during the simulation
	long sum_line = 0; // cumulative line length
	int wait_time = 0; // time until autoteller is free
	long line_wait = 0; // cumulative time in line
	// running the simulation
	for (int cycle = 0; cycle < cyclelimit; cycle++)
	{
		if (newcustomer(min_per_cust)) // have newcomer
		{
			if (line.size() == qs)
				turnaways++;
			else
			{
				customers++;
				temp.set(cycle); // cycle = time of arrival
				line.push(temp); // add newcomer to line
			}
		}
		if (wait_time <= 0 && !line.empty())
		{
			temp = line.front(); // attend next customer
			line.pop();
			wait_time = temp.ptime(); // for wait_time minutes
			line_wait += cycle - temp.when();
			served++;
		}
		if (wait_time > 0)
			wait_time--;
		sum_line += line.size();
	}
	// reporting results
	if (customers > 0)
	{
		cout << "customers accepted: " << customers << endl;
		cout << " customers served: " << served << endl;
		cout << " turnaways: " << turnaways << endl;
		cout << "average queue size: ";
		cout.precision(2);
		cout.setf(ios_base::fixed, ios_base::floatfield);
		cout << (double) sum_line / cyclelimit << endl;
		cout << " average wait time: "
			<< (double) line_wait / served << " minutes\n";
	}
	else
		cout << "No customers!\n";
	cout << "Done!\n";
}
Exemplo n.º 28
0
int main() {
	vector<items> vectorOfItems; //creates the vector of items
	vector<employees> vectorOfEmployees; //creates the vector of employees

	vector<items> recommendedItems; //creates the vector of recommended items

	int currentEmployee;

	// the following code is an example of what can be held in the database
	int example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("ball", 2.50, 1.10, 2, 5, 1));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("rubix's cube", 3.75, 1.25, 2, 1, 5));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("coloring book", 2.25, .50, 4, 1, 2));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("keyboard", 25.50, 20, 4, 1, 4));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("dance lessons", 15.50, 6.50, 5, 5, 4));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("chalk", 5.25, 2.75, 5, 4, 1));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("exercise machine", 175.25, 125.00, 1, 4, 4));
		example++;
	}
	example = 0;
	while (example < 3)
	{
		vectorOfItems.push_back(items("pinwheel", 1.25, 0.50, 2, 1, 1));
		example++;
	}

	//initial prompt for user to select employee or customer
	cout << "Welcome to the shop! Are you an employee or customer?" << endl;
	cout << "1. Employee" << endl;
	cout << "2. Customer" << endl;
	cout << "3. Exit Shop" << endl;
	string userInput = "";
	int firstInput = 0;
	bool hello = true;

	while (firstInput != 1 && firstInput != 2 && firstInput != 3) { //input validation for the first menu choice
		bool isNum = true;
		cout << endl;
		getline(cin, userInput);
		//the following for loop checks to see if the user inputed a number
		for (size_t i = 0; i < userInput.length(); i++) {
			if (!isdigit(userInput.at(i))) {
				isNum = false;
			}
		}
		
		//if the input is a number, convert the string to an int which will dictate where the code continues
		if (isNum) {
			firstInput = atoi(userInput.c_str());
		}
		if (firstInput == 1) { //entry points for the employee login
			cout << "AUTHORIZATION REQUIRED. PLEASE ENTER COMPANY PASSWORD." << endl;
			string pw = "";
			getline(cin, pw);
			if (!authorizationCheck(pw)) {
				cout << "UNAUTHORIZED ACCESS TO SYSTEM DATABASE. RETURNING TO ENTRY POINT." << endl << endl;
				cout << "Welcome to the shop! Are you an employee or customer?" << endl;
				cout << "1. Employee" << endl;
				cout << "2. Customer" << endl;
				cout << "3. Exit Shop" << endl;
				firstInput = -1;
			}
			cout << endl;
		}
		if (firstInput == 1) {
			if (hello) { //only prints the "Hello Employee!" statement once so as to not sound redundant
				cout << "Hello Employee! Please login or register for an account." << endl;
				hello = false;
			}
			cout << "1. Login" << endl;
			cout << "2. Register" << endl;
			cout << "3. Exit" << endl;
			int secondInput = 0;
			string secondUserInput = "";
			while (secondInput != 1 && secondInput != 2 && secondInput != 3) {
				bool isNum2 = true;
				cout << endl;
				getline(cin, secondUserInput);
				for (size_t i = 0; i < secondUserInput.length(); i++) {
					if (!isdigit(secondUserInput.at(i))) {
						isNum2 = false;
					}
				}
				if (isNum2) {
					secondInput = atoi(secondUserInput.c_str());
				}
				if (secondInput == 1) {
					string username;
					string password;
					cout << "LOGIN SCREEN" << endl;
					cout << "Username: "******"Password: "******"";
						int loggedInInput = 0;
						bool isNum3 = true;
						while (loggedInInput != 1 && loggedInInput != 2 && loggedInInput != 3 && loggedInInput != 4 && loggedInInput != 5) {
							isNum3 = true;
							if (loginFirstTime) {
								cout << endl << "Login successful." << endl;
							}
							loginFirstTime = false;
							cout << "What would you like to do?" << endl;
							cout << "1. Restock" << endl;
							cout << "2. Make a sale" << endl;
							cout << "3. Check inventory" << endl;
							cout << "4. Check total sales" << endl;
							cout << "5. Logout" << endl;
							cout << endl;
							getline(cin, userLoggedInInput);
							if (userLoggedInInput.length() == 0) {
								isNum3 = false;
							}
							for (size_t i = 0; i < userLoggedInInput.length(); i++) {
								if (!isdigit(userLoggedInInput.at(i))) {
									isNum3 = false;
								}
							}
							if (isNum3) {
								loggedInInput = atoi(userLoggedInInput.c_str());
							}
							if (loggedInInput == 1) { //RESTOCK METHOD
								//takes in input for creativity/activity/complexity
								//creates item
								//pushes on to vectorOfItems

								//VALUES ARE TEMPORARY
								int creativity = 0;
								int activity = 0;
								int complexity = 0;
								double cost = 0;
								string costStr = "";
								string creativityStr = "";
								string activityStr = "";
								string complexityStr = "";
								string name = "";
								string n = "";
								// make name all lowercase
								double price = 0;
								string priceStr = "";
								cout << "What is the name of item you'd like to restock?" << endl;
								getline(cin, n);
								while (!isValidString(n)) { //input validation for string. String cannot be empty
									cout << "Error. The name of the item cannot be empty. Plase re-enter the name of the item." << endl;
									getline(cin, n);
								}
								size_t counter = 0;
								char c;
								while (counter < n.length()) //converts all characters in string to lowercase
								{
									c = n[counter];
									if (isupper(c))
									{
										n[counter] = tolower(c);
									}
									counter++;
								}
								name = n;
								counter = 0;
								size_t counter2 = 0;
								string restockchoiceStr = "";
								int restockchoice = 0;
								bool alreadychecked = false; //boolean to see if the vector has been searched through once for the item
								bool usingprevious = false;
								vector<items> vectorOfCheckedItems;
								while (counter < vectorOfItems.size()) // checks to see if an item with the same name has already been added to the inventory, and prompts user if they would like to use these stats
								{
									while (counter2 < vectorOfCheckedItems.size()) // checks to see if the item is the same as what has previously been offered
									{
										if ((vectorOfCheckedItems[counter2].getItemName() == vectorOfItems[counter].getItemName()) && (vectorOfCheckedItems[counter2].getItemPrice() == vectorOfItems[counter].getItemPrice()) && (vectorOfCheckedItems[counter2].getItemCreativity() == vectorOfItems[counter].getItemCreativity()) && (vectorOfCheckedItems[counter2].getItemActivity() == vectorOfItems[counter].getItemActivity()) && (vectorOfCheckedItems[counter2].getItemComplexity() == vectorOfItems[counter].getItemComplexity()))
										{
											alreadychecked = true;
										}
										counter2++;
									}
									if ((vectorOfItems[counter].getItemName() == name) && !alreadychecked)
									{
										cout << name << " has been found in our inventory with a price of " << vectorOfItems[counter].getItemPrice() << ", " << vectorOfItems[counter].getItemCreativity() << " Creativity, " << vectorOfItems[counter].getItemActivity() << " Activity, and " << vectorOfItems[counter].getItemComplexity() << " complexity. Would you like to use these statistics?" << endl;
										cout << "1. Yes" << endl;
										cout << "2. No" << endl;
										getline(cin, restockchoiceStr);
										if (isNumber(restockchoiceStr)) { //input validation for the restockchoice variable
											restockchoice = atoi(restockchoiceStr.c_str());
										}
										while (!isNumber(restockchoiceStr) || (restockchoice != 1 && restockchoice != 2)) {
											cout << "Not a valid choice. Please enter 1 for Yes and 2 for No." << endl;
											getline(cin, restockchoiceStr);
											if (isNumber(restockchoiceStr)) {
												restockchoice = atoi(restockchoiceStr.c_str());
											}
										}
										//if the user wants to use same data from the previous item, create a duplicate
										//and push it into the inventory
										if (restockchoice == 1)
										{
											price = vectorOfItems[counter].getItemPrice();
											cost = vectorOfItems[counter].getItemCost();
											creativity = vectorOfItems[counter].getItemCreativity();
											activity = vectorOfItems[counter].getItemActivity();
											complexity = vectorOfItems[counter].getItemComplexity();
											usingprevious = true;
											break;
										}
										//otherwise create a item and push it into the inventory
										else if (restockchoice == 2)
										{
											vectorOfCheckedItems.push_back(vectorOfItems[counter]);
										}
									}

									counter++;
								}
								if (!usingprevious)
								{
									cout << "What is the selling price for this item?" << endl;
									cout << "$";
									getline(cin, priceStr);
									if (isDouble(priceStr)) { //input validation for the price variable
										price = atof(priceStr.c_str());
										//rounds the price to two decimals
										price = floor((100.*price) + .5) / 100.;
									}
									while (!isDouble(priceStr)) {
										cout << "Not a valid choice. Please enter a valid price." << endl;
										getline(cin, priceStr);
										if (isDouble(priceStr)) {
											price = atof(priceStr.c_str());
											//rounds the price to two decimals
											price = floor((100.*price) + .5) / 100.;
										}
									}
									cout << "What is the cost of making this item?" << endl; // dis dat shit
									cout << "$";
									getline(cin, costStr);
									cost = atof(costStr.c_str());
									//rounds the price to two decimals
									cost = floor((100.*cost) + .5) / 100.;
									while (!isDouble(costStr) || (cost > price)) {
										cout << "Not a valid choice. Please enter a valid cost." << endl;
										getline(cin, costStr);
										if (isDouble(costStr)) {
											cost = atof(costStr.c_str());
											//rounds the price to two decimals
											cost = floor((100.*cost) + .5) / 100.;
										}
									}
									cout << "What is the creativity value associated with the item? (Scale of 1-5)" << endl;
									getline(cin, creativityStr);
									if (isNumber(creativityStr)) { //input validation for the creativity variable
										creativity = atoi(creativityStr.c_str());
									}
									while (!isNumber(creativityStr) || creativity < 1 || creativity > 5) {
										cout << "Not a valid choice. Please enter an integer value between 1 and 5 inclusive." << endl;
										getline(cin, creativityStr);
										if (isNumber(creativityStr)) {
											creativity = atoi(creativityStr.c_str());
										}
									}
									cout << "What is the activity value associated with the item? (Scale of 1-5)" << endl;
									getline(cin, activityStr);
									if (isNumber(activityStr)) { //input validation for the activity variable
										activity = atoi(activityStr.c_str());
									}
									while (!isNumber(activityStr) || activity < 1 || activity > 5) {
										cout << "Not a valid choice. Please enter an integer value between 1 and 5 inclusive." << endl;
										getline(cin, activityStr);
										if (isNumber(activityStr)) {
											activity = atoi(activityStr.c_str());
										}
									}
									cout << "What is the complexity value associated with the item? (Scale of 1-5)" << endl;
									getline(cin, complexityStr);
									if (isNumber(complexityStr)) { //input validation for the complexity variable
										complexity = atoi(complexityStr.c_str());
									}
									while (!isNumber(complexityStr) || complexity < 1 || complexity > 5) {
										cout << "Not a valid choice. Please enter an integer value between 1 and 5 inclusive." << endl;
										getline(cin, activityStr);
										if (isNumber(complexityStr)) {
											complexity = atoi(complexityStr.c_str());
										}
									}
								}

								vectorOfItems.push_back(items(name, price, cost, creativity, activity, complexity));
								cout << name << " successfully restocked!" << endl;
								loggedInInput = 0; //need this so the loop continues until it exits
							}

							else if (loggedInInput == 2)
							{
								//takes in input of item name
								//removes first found item from vectorOfItems
								//add to sale count of employee -> increments value of count for employee
								// again this would be better in main function because we can keep track of employee with a variable equal to the username
								string purchaseName;
								bool success = false;
								// make all lowercase
								cout << "What was the name of the item you sold?" << endl;
								getline(cin, purchaseName);
								size_t counter = 0;
								char c;
								while (counter < purchaseName.length()) //converts all characters in string to lowercase
								{
									c = purchaseName[counter];
									if (isupper(c)) //if the character at c is uppercase, convert it to lowercase
									{
										purchaseName[counter] = tolower(c);

									}
									counter++; //counter to interate through the length of the name
								}

								for (size_t i = 0; i < vectorOfItems.size(); i++)
								{
									if (purchaseName == vectorOfItems[i].getItemName())
									{
										cout << "We have found a(n) " << purchaseName << " with a price of $" << fixed << setprecision(2) << vectorOfItems[i].getItemPrice() << " Proceed with transaction?" << endl;
										cout << "1. Yes" << endl;
										cout << "2. No" << endl;
										int pchoice = 0;
										string pchoiceStr = "";
										getline(cin, pchoiceStr);
										if (isNumber(pchoiceStr)) { //input validation for the complexity variable
											pchoice = atoi(pchoiceStr.c_str());
										}
										while (!isNumber(pchoiceStr) || (pchoice != 1 && pchoice != 2)) {
											cout << "Not a valid choice. Please enter 1 for Yes or 2 for No." << endl;
											getline(cin, pchoiceStr);
											if (isNumber(pchoiceStr)) {
												pchoice = atoi(pchoiceStr.c_str());
											}
										}
										if (pchoice == 1) //adds total profit to sales
										{
											vectorOfEmployees[currentEmployee].setEmpTotalSales(vectorOfEmployees[currentEmployee].getEmpTotalSales() + vectorOfItems[i].getItemProfit());
											vectorOfItems.erase(vectorOfItems.begin() + i);//deletes item in vector
											cout << "Successful Transaction. You have earned a profit of $" << fixed << setprecision(2) << vectorOfItems[i].getItemProfit() << endl << endl;;
											success = true; //changes the success variable to true so as to not print the error
											i--; //allows full iteration through
										}
									}
								}
								if (!success)
								{
									cout << "Failed to sell item! Item not found in inventory." << endl;
								}
								loggedInInput = 0;
							}

							else if (loggedInInput == 3)
							{
								//loops through vectorOfItems and prints each itemName and itemPrice, consolidating duplicates
								vector<items> itemsWithoutDupes;
								vector<int> itemcounts;
								size_t dupescounter = 0;
								size_t dcc = 0;
								size_t dccc = -1;
								bool duplicate = false;
								cout << "Current in stock: " << endl;
								while (dupescounter < vectorOfItems.size())
								{
									duplicate = false;
									dcc = 0;
									while ((dcc < itemsWithoutDupes.size()) && (dcc < itemsWithoutDupes.size()))
									{
										if (vectorOfItems[dupescounter].getItemName() == itemsWithoutDupes[dcc].getItemName())
										{
											duplicate = true;
										}
										dcc++;
									}
									if (!duplicate) //if this is a new thing add a new item count, and itemwithoutdupes, then count to see how many items are duplicated
									{
										itemcounts.push_back(0);
										itemsWithoutDupes.push_back(vectorOfItems[dupescounter]);
										dccc++;
										dcc = 0;
										while (dcc < vectorOfItems.size())
										{
											if (vectorOfItems[dcc].getItemName() == itemsWithoutDupes[dccc].getItemName())
											{
												itemcounts[dccc]++;
											}
											dcc++;
										}

									}
									else
									{

									}
									dupescounter++;
								}

								for (size_t i = 0; i < itemsWithoutDupes.size(); i++)
								{
									cout << "Item: " << itemsWithoutDupes[i].getItemName() << endl << "Price: $" << fixed << setprecision(2) << itemsWithoutDupes[i].getItemPrice() << endl << "Profit Per Sale: $" << itemsWithoutDupes[i].getItemProfit() << endl << "Quantity: " << itemcounts[i] << endl << "----------------------" << endl;
								}
								loggedInInput = 0;
							}

							else if (loggedInInput == 4)
							{
								cout << "Employee " << vectorOfEmployees[currentEmployee].getEmpName() << " has sold items in total of $" << fixed << setprecision(2) << vectorOfEmployees[currentEmployee].getEmpTotalSales() << endl;
								loggedInInput = 0;
							}

							else if (loggedInInput == 5)
							{
								cout << "Logout successful." << endl;
								secondInput = 0;
							}
							else
							{
								cout << "Error. Not a valid choice. Please try again." << endl;
								loggedInInput = 0;
							}
						} //end of Employee options loop
					//} // end of while loop for user logged in
					}
					else { //if (!isAuthenticated)
						secondInput = 0;
						hello = true;
						cout << endl << "Login Unsuccesful. Invalid username or password. Please try again." << endl;
					}
				}

				else if (secondInput == 2) { //entry point for new account registration
					string name = "";
					string username = "";
					string password = "";
					cout << "NEW ACCOUNT REGISTRATION SCREEN" << endl;
					cout << "Please enter the following information to register for a new account." << endl;
					cout << "Name: ";
					getline(cin, name);
					cout << "Username: "******"Password: "******"Thank you for registering, " << name << "! Please log in with your new credentials." << endl << endl;
						secondInput = 0;
					}
					else
					{
						//prints and loop will run again
						cout << "Username already taken!" << endl << endl;
						secondInput = 0;
					}
				}

				else if (secondInput == 3) { //go back to the employee or customer selection menu
					firstInput = 0;
					cout << "Welcome to the shop! Are you an employee or customer?" << endl;
					cout << "1. Employee" << endl;
					cout << "2. Customer" << endl;
					cout << "3. Exit" << endl;
					hello = true;
					break;
				}
				else {
					cerr << "Error, not a valid choice. Please enter either 1 to login, 2 to register, or 3 to go back." << endl;
				}
				cout << "1. Login" << endl;
				cout << "2. Register" << endl;
				cout << "3. Exit" << endl;
			} // closing bracket for top while loop
		} //closing bracket for if employee
		if (firstInput == 2) { //entry point for customer
			string cn = "";
			string ageStr = "";
			int age = 0;
			double budget = 0.0;
			cout << "Hello customer! Please enter your name" << endl;
			getline(cin, cn);
			cout << endl << "Please enter your age" << endl;
			getline(cin, ageStr);
			while (!isNumber(ageStr)) {
				cout << endl << "Not a valid age. Please enter a positive integer." << endl;
				getline(cin, ageStr);
			}
			age = atoi(ageStr.c_str());

			cout << endl << "How much money are you looking to spend today?" << endl;
			string budgetStr = "";
			getline(cin, budgetStr);
			while (!isDouble(budgetStr)) {
				cout << "Please enter a valid dollar amount." << endl;
				getline(cin, budgetStr);
			}
			budget = atof(budgetStr.c_str());

			Customer *user = new Customer(cn, age, budget); //creates a new instance of a customer

			cout << endl << "Hello " << user->getCustomerName() << "! Would would you like to do today?" << endl;
			cout << "1. Purchase item" << endl;		//search by name, instock? remove from list, display price
			cout << "2. Find gift" << endl;			//go to questionnaire
			cout << "3. Display all" << endl;		//loop through vector and print inventory
			cout << "4. Check current budget" << endl;
			cout << "5. Update current budget" << endl;
			cout << "6. Go back" << endl;

			bool keepgoing = true;
			int secondinput = 0;
			string input1 = "";
			while (secondinput != 1 && secondinput != 2 && secondinput != 3 && secondinput != 4 && secondinput != 5 && secondinput != 6 && keepgoing) {
				bool isNum1 = true;
				cin >> input1; //input validation
				for (size_t j = 0; j < input1.length(); j++) {
					if (!isdigit(input1.at(j))) {
						isNum1 = false;
					}
				}
				if (isNum1) {
					secondinput = atoi(input1.c_str());
				}
				if (secondinput == 1) { //entry point for item purchase within customer class
					purchaseItem(vectorOfItems, *user);
					secondinput = 0;
				}
				else if (secondinput == 2) { //entry point for the questionnaire
					recGift(vectorOfItems, recommendedItems, *user);
					secondinput = 0;
				}
				else if (secondinput == 3) {
					display(vectorOfItems);
					secondinput = 0;
				}
				else if (secondinput == 4) {
					cout << "You're current reminaing budget is $" << fixed << setprecision(2) << user->getCustomerBudget() << endl;
					cout << endl;
					secondinput = 0;
				}
				else if (secondinput == 5) {
					cout << "How much money would you like to add?" << endl;
					cout << "$";
					double addbudget = 0;
					string addbudgetStr = "";
					getline(cin, addbudgetStr);
					while (!isDouble(addbudgetStr)) {
						cout << "Please enter a valid dollar amount." << endl;
						getline(cin, addbudgetStr);
					}
					addbudget = atof(addbudgetStr.c_str());
					user->addBudget(addbudget);
					cout << "$" << fixed << setprecision(2) << addbudget << " successfully added to the budget!" << endl;
					secondinput = 0;
				}
				else if (secondinput == 6) { //exit function to return to employee/customer select screen
					firstInput = -1;
					cout << endl;
					cout << "Welcome to the shop! Are you an employee or customer?" << endl;
					cout << "1. Employee" << endl;
					cout << "2. Customer" << endl;
					cout << "3. Exit" << endl;
					hello = true;
					break;
				}
				else {
					cerr << endl << "Error, not a valid choice. " << endl;
				}
				cout << "1. Purchase item" << endl;
				cout << "2. Find gift" << endl;
				cout << "3. Display all" << endl;
				cout << "4. Check current budget" << endl;
				cout << "5. Update current budget" << endl;
				cout << "6. Go back" << endl;
			}
		}//closing bracket for if customer
		if (firstInput == 3) { //this is how to the user exists the shop
			cout << "Are you sure you want to leave? Please enter 1 for yes or 2 for no" << endl;
			string exitOptionStr = "";
			int exitOption = 0;
			getline(cin, exitOptionStr);
			if (isNumber(exitOptionStr)) { //input validation for the exitOption variable
				exitOption = atoi(exitOptionStr.c_str());
			}
			while (!isNumber(exitOptionStr) || (exitOption != 1 && exitOption != 2)) {
				cout << "Not a valid choice. Please enter 1 for Yes and 2 for No." << endl;
				getline(cin, exitOptionStr);
				if (isNumber(exitOptionStr)) {
					exitOption = atoi(exitOptionStr.c_str());
				}
			}
			//returns back to the main menu when the user does not want to exit the program
			if (exitOption == 2) {
				firstInput = -1;
				cout << endl;
				cout << "Welcome to the shop! Are you an employee or customer?" << endl;
				cout << "1. Employee" << endl;
				cout << "2. Customer" << endl;
				cout << "3. Exit Shop" << endl;
			}
			//safely exists the program
			if (exitOption == 1)
			{
				exit(EXIT_SUCCESS);
			}
		}
		if (firstInput == 0 || firstInput == -1)
		{

		}
		else if (!(firstInput == 1 || firstInput == 2 || firstInput == 3))
		{
			cout << "Error, not a valid choice. Please enter either 1 for employee, 2 for customer or 3 to exit the shop." << endl;
		}
			firstInput = 0;
	} //closing bracket for the outermost while loop which checks for user validation
void MainProgramWindow::on_pushButton_Login_clicked()
{
	Admin	Administrator("admin","*****@*****.**", 1234, "password");
	int		customerLocation;
	bool	validInput = false;
	QString tempName;
	QString tempPassword;
	Login   loginWindow;
	ErrorLogin errorWindow;
	Customer tempCustomer;


	customerLocation = 0;
	loginWindow.setModal(true);
    int success = loginWindow.exec();
	loginWindow.on_buttonBox_loginPress_accepted(tempName, tempPassword);

	// Stores the tempname and password
	SetUsername(tempName);
	SetPassword(tempPassword);

	if(Administrator.checkAdmin(tempName, tempPassword ))
	{
		validInput = true;
		SetAdminLogin(true);
	}
	else
	{	// Compare user input to database

        try
        {
            tempCustomer = customerList.FindCustomer(tempName);

            if (tempCustomer.getAccess() && tempCustomer.getPassword() == tempPassword)
            {
                validInput = true;
                SetCustomerLogin(true);
            }
            else if (tempCustomer.getPassword() != tempPassword)
            {
                QMessageBox::information(this,"Error", "Wrong Credentials, sorry.");
            }
            else
            {
                QMessageBox::information(this,"Message", "Your account has not been activated yet. An administrator needs to activate your account, thank you for your patience!");

            }

        }
        catch (NotFound)
        {
            if (success)
            {
                QMessageBox::information(this,"Error", "Account not found, sorry.");
            }
        }
        catch(...)
        {

        }


	}

	if(validInput)
	{
		if(adminLogin)
		{
			aWindow->show();	// ADMIN
		}
		else if(customerLogin)
		{
			if(tempCustomer.getAccess())
			{

				bWindow->show();    // BROCHURE
            }
		}


	}

    //restore defaults
    SetAdminLogin(false);
    SetCustomerLogin(false);

}
Exemplo n.º 30
0
int main (void)
{
	
   //setting up the 5 lines of cashiers
   Cashier cashier1;
   Cashier cashier2;
   Cashier cashier3;
   Cashier cashier4;
   Cashier cashier5;

   //creating Customer variable to temporarily hold input
   Customer cust;

   //creating queue to hold input from file
   queue<Customer> custInput;

   //creating variable to hold simulation data
   Sim_data_type sim;

   //file for getting input
   ifstream in_file;		

   //used to temperarily hold the line obtained from the file
   string line;

   //used to temperarily hold the selected substring
   string substring;			

   //opening file
   in_file.open("output.dat"); 
   if( in_file.fail() )
   {

      cout<<"Could not open file.\n";
      return 0;
   }
   else
   {

       //get data from file until end of file
	    while( !in_file.eof() )	
	    {

		    //gets input until new line
		    getline( in_file, line );

		    //if extracted string isn't empty 
		    if( line.length() > 0 ) 
		    {
                   
             //getting the first digits for (number)
             substring = line.substr(0, 2);
                  
             cust.set_number( atoi(substring.c_str()) );
                     
             //getting the next digits for (arrival_time)
             substring = line.substr(4, 4);
                   
             cust.set_arrival_time( atoi(substring.c_str()) );

             //getting the next digits for (serv_time)
             substring = line.substr(9, 3);

             cust.set_serv_time( atoi(substring.c_str()) );

             //adding newly created customer to the data queue
             custInput.push( cust );

          }
      }

	   //closing file
	   in_file.close();
   }

   //while store not closed
	while( sim.get_cnt() < 600 )
   {
                  
      //increment minutes
      sim.inc_cnt();
      cashier1.inc_timer();
      cashier2.inc_timer();
      cashier3.inc_timer();
      cashier4.inc_timer();
      cashier5.inc_timer();

      //while customers can still be served
      if( sim.get_cnt() < 570 )
      {
         
         //set cust to temporarily hold front of custInput
         cust = custInput.front();

         //if the front of queue is ready to join line
         while( cust.get_arrival_time() == sim.get_cnt() )
         {
            
            //set the customer to the first available/shortest
            //lane; if none are open turn them away
            if( 
                cashier1.get_status() == 'a' && 
               (cashier2.get_status() == 'i' ||
                cashier1.get_in_line() <= cashier2.get_in_line()) &&
               (cashier3.get_status() == 'i' ||
                cashier1.get_in_line() <= cashier3.get_in_line()) &&
               (cashier4.get_status() == 'i' ||
                cashier1.get_in_line() <= cashier4.get_in_line()) &&
               (cashier5.get_status() == 'i' ||
                cashier1.get_in_line() <= cashier5.get_in_line()) 
              )
            {       
               
               //adding customers serv time to cashiers queue
               cashier1.add_customer( cust.get_serv_time() );   

               //removing customer from input we added to queue
               custInput.pop();

               //setting cust to new front so while checks correctly
               cust = custInput.front();  
            }
            else if( 
                cashier2.get_status() == 'a' && 
               (cashier1.get_status() == 'i' ||
                cashier2.get_in_line() <= cashier1.get_in_line()) &&
               (cashier3.get_status() == 'i' ||
                cashier2.get_in_line() <= cashier3.get_in_line()) &&
               (cashier4.get_status() == 'i' ||
                cashier2.get_in_line() <= cashier4.get_in_line()) &&
               (cashier5.get_status() == 'i' ||
                cashier2.get_in_line() <= cashier5.get_in_line()) 
              )
            {

               cashier2.add_customer( cust.get_serv_time() );

               custInput.pop();

               cust = custInput.front();
            }
            else if( 
                cashier3.get_status() == 'a' && 
               (cashier2.get_status() == 'i' ||
                cashier3.get_in_line() <= cashier2.get_in_line()) &&
               (cashier1.get_status() == 'i' ||
                cashier3.get_in_line() <= cashier1.get_in_line()) &&
               (cashier4.get_status() == 'i' ||
                cashier3.get_in_line() <= cashier4.get_in_line()) &&
               (cashier5.get_status() == 'i' ||
                cashier3.get_in_line() <= cashier5.get_in_line()) 
              )
            {

               cashier3.add_customer( cust.get_serv_time() );

               custInput.pop();

               cust = custInput.front();
            }
            else if( 
                cashier4.get_status() == 'a' && 
               (cashier2.get_status() == 'i' ||
                cashier4.get_in_line() <= cashier2.get_in_line()) &&
               (cashier3.get_status() == 'i' ||
                cashier4.get_in_line() <= cashier3.get_in_line()) &&
               (cashier1.get_status() == 'i' ||
                cashier4.get_in_line() <= cashier1.get_in_line()) &&
               (cashier5.get_status() == 'i' ||
                cashier4.get_in_line() <= cashier5.get_in_line()) 
              )
            {

               cashier4.add_customer( cust.get_serv_time() );

               custInput.pop();
         
               cust = custInput.front();
            }
            else if( 
                cashier5.get_status() == 'a' && 
               (cashier2.get_status() == 'i' ||
                cashier5.get_in_line() <= cashier2.get_in_line()) &&
               (cashier3.get_status() == 'i' ||
                cashier5.get_in_line() <= cashier3.get_in_line()) &&
               (cashier4.get_status() == 'i' ||
                cashier5.get_in_line() <= cashier4.get_in_line()) &&
               (cashier1.get_status() == 'i' ||
                cashier5.get_in_line() <= cashier1.get_in_line()) 
              )
            {

               cashier5.add_customer( cust.get_serv_time() );

               custInput.pop();

               cust = custInput.front();
            }
            else
            {
               sim.inc_num_turned_away();
            }

         }

      }

      //increment sim variables for output later
      //if cashiers timer = the serv time of cust 
      //then remove that cust
      if( cashier1.get_timer() == cashier1.get_curr_cust_time_limit() )
      {

         //add the customer-to-be-removed's wait time to total wait
         sim.add_tot_wait_time( cashier1.get_curr_cust_time_limit() );  

         //remove it front queue
         cashier1.rmv_frnt_cust();
         
         //increment the total number serviced
         sim.inc_num_serviced();
      }
      if( cashier2.get_timer() == cashier2.get_curr_cust_time_limit() )
      {
   
         sim.add_tot_wait_time( cashier2.get_curr_cust_time_limit() );

         cashier2.rmv_frnt_cust();

         sim.inc_num_serviced();
      }
      if( cashier3.get_timer() == cashier3.get_curr_cust_time_limit() )
      {

         sim.add_tot_wait_time( cashier3.get_curr_cust_time_limit() );

         cashier3.rmv_frnt_cust();

         sim.inc_num_serviced();
      }
      if( cashier4.get_timer() == cashier4.get_curr_cust_time_limit() )
      {

         sim.add_tot_wait_time( cashier4.get_curr_cust_time_limit() );

         cashier4.rmv_frnt_cust();

         sim.inc_num_serviced();
      }
      if( cashier5.get_timer() == cashier5.get_curr_cust_time_limit() )
      {

         sim.add_tot_wait_time( cashier5.get_curr_cust_time_limit() );

         cashier5.rmv_frnt_cust();

         sim.inc_num_serviced();
      }

   }

   //final output
   cout<<"Total number of customers serviced: "<<sim.get_num_serviced();
   cout<<endl<<"Total number of customers turned away: "
             <<sim.get_num_turned_away();
   cout<<endl<<"Average wait time: "<<sim.get_avg_wait_time()<<endl;

   //exit program
   return 0;

}