Пример #1
0
TEST(customer, DualNewReleaseStatement)
{
	Customer customer("Fred");
	customer.addRental(Rental(Movie ("The Cell", Movie::NEW_RELEASE), 3));
	customer.addRental(Rental(Movie ("The Tigger Movie", Movie::NEW_RELEASE), 3));
    EXPECT_STREQ("Rental Record for Fred\n\tThe Cell\t9.0\n\tThe Tigger Movie\t9.0\nYou owed 18.0\nYou earned 4 frequent renter points\n", customer.statment().c_str());
}
Пример #2
0
int main() {
    if(!isRunning())//checking whether the server is running or not
        printf("Stocks server is not running! Please run the stocks server before running the client!\n");
    else {
        do {
            printf("\n\tVirtual Stock Market Management System\n\t---------------------------------------\n\n");
            printf("1. Company Login - Create stocks and view current prices/analysis\n");
            printf("2. Customer Login - Buy and Sell Stocks\n");
            printf("3. Exit\n\n");
            printf("Enter choice:");
            scanf("%d",&c);
            switch(c) {
            case 1:
                company();
                break;
            case 2:
                customer();
                break;
            case 3:
                quit();
                break;
            default:
                printf("Invalid choice! Enter again.\n\n");
            }
        } while(!q);
    }
    return 0;
}
Пример #3
0
	std::wstring render(bool propper, std::wstring syntax, std::wstring date_format = DATE_FORMAT, DWORD langId = 0) const {
		if (propper) {
			// To obtain the appropriate message string from the message file, load the message file with the LoadLibrary function and use the FormatMessage function
			strEx::replace(syntax, _T("%message%"), render_message(langId));
		} else {
			strEx::replace(syntax, _T("%message%"), _T("%message% needs the descriptions flag set!"));
		}

		strEx::replace(syntax, _T("%source%"), get_source());
		strEx::replace(syntax, _T("%computer%"), get_computer());
		strEx::replace(syntax, _T("%generated%"), strEx::format_date(get_time_generated(), date_format));
		strEx::replace(syntax, _T("%written%"), strEx::format_date(get_time_written(), date_format));
		strEx::replace(syntax, _T("%generated-raw%"), strEx::itos(pevlr_->TimeGenerated));
		strEx::replace(syntax, _T("%written-raw%"), strEx::itos(pevlr_->TimeWritten));
		strEx::replace(syntax, _T("%type%"), translateType(eventType()));
		strEx::replace(syntax, _T("%category%"), strEx::itos(pevlr_->EventCategory));
		strEx::replace(syntax, _T("%facility%"), strEx::itos(facility()));
		strEx::replace(syntax, _T("%qualifier%"), strEx::itos(facility()));
		strEx::replace(syntax, _T("%customer%"), strEx::itos(customer()));
		strEx::replace(syntax, _T("%rawid%"), strEx::itos(raw_id()));
		strEx::replace(syntax, _T("%severity%"), translateSeverity(severity()));
		strEx::replace(syntax, _T("%strings%"), enumStrings());
		strEx::replace(syntax, _T("%log%"), file_);
		strEx::replace(syntax, _T("%file%"), file_);
		strEx::replace(syntax, _T("%id%"), strEx::itos(eventID()));
		strEx::replace(syntax, _T("%user%"), userSID());
		return syntax;
	}
Пример #4
0
TEST(customer, MultipleRegularStatement)
{
	Customer customer("Fred");
	customer.addRental(Rental(Movie ("Plan 9 from Outer Space", Movie::REGULAR), 1));
	customer.addRental(Rental(Movie ("8 1/2", Movie::REGULAR), 2));
	customer.addRental(Rental(Movie ("Eraserhead", Movie::REGULAR), 3));
    EXPECT_STREQ("Rental Record for Fred\n\tPlan 9 from Outer Space\t2.0\n\t8 1/2\t2.0\n\tEraserhead\t3.5\nYou owed 7.5\nYou earned 3 frequent renter points\n", customer.statment().c_str());
}
Пример #5
0
Store::Store(){
   this->console = Console();
   this->console.refresh();                 // setup the console.
   this->loadMovies();                      // load movies.
   this->customers = customerCollection();  // load default customers.
   this->customers.addCustomer(customer()); // add staff member.
   this->login();
} // end Store::Store();
Пример #6
0
int main() {
  semaphore customer_waiting = 0;
  binary_semaphore barber_sleeping=1;
  parbegin
    barber();
    while(true) customer();
  parend;
  return 0;
}
Пример #7
0
int main()
{
 n=10;
 if((mutex=semget(IPC_PRIVATE,1,0666|IPC_CREAT))==-1)
 {
  printf("error in creation of semaphore\n");
  exit(1);
 }
 if((semctl(mutex,0,SETVAL,1))==-1)
 {
  printf("erroe in settting value\n");
  exit(1);
 }
 if((custc=semget(IPC_PRIVATE,1,0666|IPC_CREAT))==-1)
 {
  printf("error in creation of semaphore\n");
  exit(1);
 }
 if((semctl(custc,0,SETVAL,1))==-1)
 {
  printf("erroe in settting value\n");
  exit(1);
 }
 if((shm=(shmget(IPC_PRIVATE,n*sizeof(int),0666|IPC_CREAT)))==-1)
 {
  printf("error in creation of shared memory\n");
  exit(1);
 }
 ARR=(int *)shmat(shm,(void *)0,0);
 if((f=(shmget(IPC_PRIVATE,sizeof(int),0666|IPC_CREAT)))==-1)
 {
  printf("error in creation of shared memory\n");
  exit(1);
 }
 if((r=(shmget(IPC_PRIVATE,sizeof(int),0666|IPC_CREAT)))==-1)
 {
  printf("error in creation of shared memory\n");
  exit(1);
 }
 if((c=(shmget(IPC_PRIVATE,sizeof(int),0666|IPC_CREAT)))==-1)
 {
  printf("error in creation of shared memory\n");
  exit(1);
 }
 cid=(int *)shmat(c,(void *)0,0);
 front=(int *)shmat(f,(void *)0,0);
 rear=(int *)shmat(r,(void *)0,0);
 int k,i;
 for(i=0;i<n;i++)
 {
  k=fork();
  if(k==0)
   customer(i+1);
 }
 barber(1);
 exit(0);
}
Пример #8
0
int main() {
  semaphore customer_waiting = 0;
  binary_semaphore barber_sleeping=1, seats_mutex=1;
  int free_seats = 5;
  // bombard barber with customers
  parbegin
    barber();
    while(true) customer();
  parend;
  return 0;
}
Пример #9
0
void OnButtonClicked_H(WM_MESSAGE * pMsg)//hand
{
	if(h_cus == NULL)
	{
	customer(pMsg);
	}
	else
	{
	LimitSpeedH(pMsg);
	}	
}
Пример #10
0
void OnButtonClicked_T(WM_MESSAGE * pMsg)//table
{
	hlimit_speed_tlimit_speed = 1;
	if(h_cus == NULL)
	{
	customer(pMsg);
	}
	else
	{
	LimitSpeedT(pMsg);
	}
}
Пример #11
0
void sim(int argc, char *argv[])
{
	set_model_name("M/M/1 Queue");
	create("sim");
	cnt = NARS;
	for(int i = 1; i <= NARS; i++) {
		hold(expntl(IAR_TM));	// interarrival interval
		customer();		// generate next customer
		}
	done.wait();			// wait for last customer to depart
	report();			// model report
	theory();
	mdlstat();			// model statistics
}
Пример #12
0
/* the customer thread function - create 10 threads, each of which calls
 * this function with its customer number 0..9
 */
void *customer_thread(void *context) 
{
    int customer_num = (int)context; 
    while(1){
       
       /* maintaing a 10 secs gap between creation of two customer threads */ 
       sleep_exp(10.0, NULL);
       
       /* calling the customer function with the customer number as the argument */ 
       customer(customer_num);
    }

    return 0;
}
Пример #13
0
int main(){
    Customer customer("Jonathan");
    MortgageFacade* mortgageLoanObj = new MortgageFacade;
    bool validity = mortgageLoanObj->IsEligible(customer);
    if ( validity )
    {
        std::cout << "First level loan check is cleared for " << customer.Name << std::endl;
    }
    else
    {
        std::cout << "First level loan check not cleared for " << customer.Name << std::endl;
    }
    while(1){;}
}
Пример #14
0
    void add(customer_info const& info) {
        boost::contract::old_ptr<int> old_count = BOOST_CONTRACT_OLDOF(count());
        boost::contract::check c = boost::contract::public_function(this)
            .precondition([&] {
                // Not already active.
                BOOST_CONTRACT_ASSERT(!id_active(info.id));
            })
            .postcondition([&] {
                BOOST_CONTRACT_ASSERT(count() == *old_count + 1); // Count inc.
                BOOST_CONTRACT_ASSERT(id_active(info.id)); // Activated.
            })
        ;

        customers_.insert(std::make_pair(info.id, customer(info)));
    }
Пример #15
0
//--------------------------------------------------------------
void ofApp::setup(){

    ofSetVerticalSync(true);
    ofSetWindowPosition(0, 0);
    ofSetFrameRate(30);

    ofEnableAlphaBlending();
    
    //Initialize place settings
    for (int i=0; i<NUM_CUSTOMERS; i++) {
        arrCustomers[i] = customer(i);
    }
    
    //Set up serial
    serial.setup(0, 9600);
    
	serial.startContinuousRead(false);
	ofAddListener(serial.NEW_MESSAGE,this,&ofApp::onNewMessage);
	
    //Register the curl async response
    ofRegisterURLNotification(this);
    
    //Init the state
    initState();
    
    font32.loadFont("Lato-Light.ttf", 32);
    
    // - - - - - - - - - - - - - - - - VIDEO SYNC! - - - [ SETUP ]- - - - - - - -
   
    
    client.setup(PORT);
    
    videoPlayer.loadMovie("testHAP.mov");
    font250.loadFont("Lato-Light.ttf", 250);
    
    bFULLSCREEN = false;
    bINFO = true;
    bPLAY = false;

    // - - - - - - - - - - - - - - - - -  FACT VIDEO TEST  - - - - - - - - - - - -
    for (int i = 0; i <4; i++)     cVideoTest[i].loadMovie("txtTrayAlpha.mov");
    bTestPlay = false;
    
}
Пример #16
0
int main() {

    // Videos
    Video lotr("Lord of the Rings", Video::REGULAR);
    Video hp("Harry Potter", Video::CHILDRENS);

    // Rentals of these movies
    Rental r1(lotr, 10);
    Rental r2(hp, 5);

    // Customer with some rentals
    Customer customer("Fred");
    customer.addRental(r1);
    customer.addRental(r2);

    // Output customer statement
	
	outputCustomerStatement(customer)
    return 0;
}
Пример #17
0
MenuResult AddCustomer::handle()
{
	time_t today = time(NULL);
	struct tm *time;
	time = localtime(&today);
	int day, month, year;
	day = time->tm_mday;
	month = time->tm_mon + 1;
	year = time->tm_year + 1900;

	Date todayDate(day, month, year);
	int id = store.getAvailableId();
	string name;
	cin.clear();
	cin.ignore(INT64_MAX, '\n');
	cout << "\nInsert customer name: ";
	getline(cin, name);
	Customer customer(id, name, todayDate, 0.00);
	store.addCustomer(customer);
	cout << "The customer has been added.\n";
	cout << "\nID: " << customer.getId() << "\nName: " << customer.getName() << "\nJoin date: " << customer.getJoinDate() << "\nAmount: " << fixed << setprecision(2) << customer.getTotalCost() << endl;
	pause();
	return CONTINUE;
}
Пример #18
0
void CControlWin::renewInfo()
{
    // 计算并存储到达客户的信息 和 下一客户到达信息
    m_pServer -> subWorkTime();
    if( m_pServer -> getRemainWorkTime() != 0 )
    {
        m_nextCounter--;
        if( m_nextCounter == 0 )
        {
            CCustomerType customer(this -> randomBusi() ,
                                     m_number ,
                                     time(NULL) ,
                                     (time_t)(this -> randomProcessTime()),
                                     (money_t)(this -> randomCusMoney()));

            m_pCusQueue -> push_back(customer);
            this -> renewQueueInfo();
            // 下一客户号 ,到达时间间隔
            m_number ++;
            m_nextCounter = this -> randomNextCustomer();

            time_t timetmp = time(NULL);
            timetmp += (time_t)m_nextCounter;
            //time(&timetmp);
            char *p = ctime(&timetmp);
            p[20]='\0';
            m_pNextVar -> setText(QString(p+11));

        }

        // 下一个交易客户
        this -> renewServerCus();

        m_pServer -> subProcessTime();
        // 交易完成,更新银行信息
        if(m_pServer -> isHadCustomer() && m_pServer -> getRemainTime() == 0 )
        {
            // 如果当前用户是还款,那么需要去检索第二个队列,查找能满足的客户并交易
            if( m_pServer -> getCurCust().getBusiType() == DEPOSIT
                    || m_pServer -> getCurCust().getBusiType() == REFUND )
            {
                m_tags = 2;
                m_preMoney = m_pServer -> getTotalMoney();
            }
            m_pServer -> setFree();
            m_pServer -> renewMoney();
            m_pServer -> reInitCusInfo();
            QString str = QString::number(m_pServer -> getTotalMoney() , 10);
            m_pCurMoneyVar -> setText(str);
            // total money less than the total when the last customer who DEPOSIT or REFUND
            if( m_pServer -> getTotalMoney() <= m_preMoney )
                m_tags = 1;
            this -> setCusTipWait();
        }
    }
    else
    {
        m_pTimer -> stop();
        this -> reInitInfo();
    }

//    static int i = 0;
//    m_pBankScene -> addLine(10,10 + i*2,100 +i,100);
//    m_pBankScene -> addRect(1,1,100,100);
//    i+=2;
//    QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);


//    QTimeLine *timer = new QTimeLine(5000);
//    timer->setFrameRange(0, 100);

//    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
//    animation->setItem(ball);
//    animation->setTimeLine(timer);

//    for (int i = 600; i > 0; --i)
//        animation->setPosAt(i / 600.0, QPointF(i, 60));
//    m_pBankScene -> addItem(ball);
//    timer -> start();

}
Пример #19
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";
	}

}
Пример #20
0
TEST(customer, SingleChildrensStatement)
{
	Customer customer("Fred");
	customer.addRental(Rental(Movie ("The Tigger Movie", Movie::CHILDRENS), 3));
    EXPECT_STREQ("Rental Record for Fred\n\tThe Tigger Movie\t1.5\nYou owed 1.5\nYou earned 1 frequent renter points\n", customer.statment().c_str());
}