Пример #1
0
/* City #1 - Rules Are Rules */
void dope::Detroit()
{
    do
    {
        system ("cls");
        Status();

        for(int i = 0; i < 32; i++)
        {
            cout << '\xb1';
        }

        cout << endl;
        cout << '\xb1' << "  Dope Prices      " << '\xb1' << "  Tools   " << '\xb1' << endl;
        cout << '\xb1' << "                   " << '\xb1' << "          " << '\xb1' << endl;
        cout << '\xb1' << " 1. Weed    = $50  " << '\xb1' << "  7. Buy  " << '\xb1' << endl;
        cout << '\xb1' << " 2. Heroin  = $10  " << '\xb1' << "  8. Sell " << '\xb1' << endl;
        cout << '\xb1' << " 3. Cocaine = $200 " << '\xb1' << "  9. Bank " << '\xb1' << endl;
        cout << '\xb1' << " 4. MJ      = $20  " << '\xb1' << " 10. Coat " << '\xb1' << endl;
        cout << '\xb1' << " 5. Ecstasy = $35  " << '\xb1' << " 11. Quit " << '\xb1' << endl;
        cout << '\xb1' << " 6. Acid    = $175 " << '\xb1' << "          " << '\xb1';
        cout << endl;

        for (int j = 0; j < 32; j++)
        {
            cout << '\xb1';
        }

        cout << endl;
        cout << "Tool Choice: ";
        cin >> decision;

        switch (decision)
        {
            case 7:
                Purchase(x, y);
                break;
            case 8:
                Sell(a, b);
                break;
            case 9:
                Bank();
                break;
            case 10:
                Coat();
                break;
            case 11:
                exit(11);
                break;
            default:
                cout << "Invalid Choice!\n";
                break;
        }
    }
    while ((decision < 7) || (decision > 11));

    return;
}
Пример #2
0
void input_purchases(Order& or) { //Creates a purchase using user input
	for(int i = 0; i < or.get_data(); ++i){
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		cout << "Purchase Name: ";		string name;	   getline(cin, name);
		cout << "Unit Price: "; double unit_price; cin >> unit_price;
		cout << "Count: ";		int count;		   cin >> count;
		or.purchases.push_back(Purchase(name, unit_price, count));
		if(i == (or.get_data() - 1))
			cin.ignore(numeric_limits<streamsize>::max(), '\n');
	}
}
Пример #3
0
Order read_order(string line){ //Returns an order from a string using same format as print_order()
	istringstream is(line);
	string name, address;
	int data;
	char c;

	//is.get calls that don't get used are to "eat up" formatting commas

	is.get(c);
	while(c != ','){
		name += c;
		is.get(c);
	}
	is.get(c);
	is.get(c);
	while(c != ','){
		address += c;
		is.get(c);
	}

	is >> data;
	Order or(name, address, data);

	for(int i = 0; i < data; ++i){
		string pur_name;
		double unit_price;
		int count;
		
		is.get(c);
		while(c != ','){
			pur_name += c;
			is.get(c);
		}
		is >> unit_price;
		is.get(c);
		is >> count;

		or.purchases.push_back(Purchase(pur_name, unit_price, count));
		c = ' ';
	}

	return or;
}
Пример #4
0
static void PerformRequest(void)
{
    char *method = getenv("REQUEST_METHOD");
    char *role = getenv("FCGI_ROLE");
    char *scriptName = PathTail(getenv("SCRIPT_NAME"));
    char *parent = "";
    char *op = QueryLookup(getenv("QUERY_STRING"), "op");
    char *item = QueryLookup(getenv("QUERY_STRING"), "item");
    char *userId =  getenv("SI_UID");
    if(userId == NULL) {
        InvalidRequest("405", "Incorrect configuration, no user id");
        goto done;
    } else {
        MarkThisCartActive(userId);
    }
    if(!strcmp(role, "RESPONDER")) {
        if(strcmp(method, "GET")) {
            InvalidRequest("405", "Only GET Method Allowed");
        } else if(op == NULL || !strcmp(op, OP_DISPLAY_STORE)) {
            DisplayStore(scriptName, parent, userId, fcgiProcessId);
	} else if(!strcmp(op, OP_ADD_ITEM)) {
            AddItemToCart(scriptName, parent, userId, fcgiProcessId, item);
	} else if(!strcmp(op, OP_DISPLAY_CART)) {
            DisplayCart(scriptName, parent, userId, fcgiProcessId);
	} else if(!strcmp(op, OP_REMOVE_ITEM)) {
            RemoveItemFromCart(scriptName, parent, userId, fcgiProcessId, item);
	} else if(!strcmp(op, OP_PURCHASE)) {
            Purchase(scriptName, parent, userId, fcgiProcessId);
	} else {
            InvalidRequest("404", "Invalid 'op' argument");
 	}
    } else if(!strcmp(role, "AUTHORIZER")) {
        Authorize(userId);
    } else {
        InvalidRequest("404", "Invalid FastCGI Role");
    }
  done:
    Free(scriptName);
    Free(op);
    Free(item);
}
Пример #5
0
int main(){

Date Today(4,18,2012);
Date Maturity(12,31,2025);
Date Purchase(2,28,2012);

Bond Y("NYC_Obligation", 885.0, Purchase, Maturity);
Bond *bond_ptr = new Bond("GW_Bridge_Obligation", 895.0, Purchase, Maturity);

int Y_days = Y.daysToMaturity(Today);
float Y_years = Y_days / 365;
cout<<"The name of the First Bond is : "<< Y.get_name() <<endl;
cout<<"The price of the First Bond is : "<< Y.get_price() << endl;
cout<<"The difference between Maturity Date and Today's Date is: "<< Y_days << " Days."<<endl;
cout<<"The difference between Maturity Date and Today's Date is: "<< Y_years << " Years."<<endl;

int ptr_days = bond_ptr -> daysToMaturity(Today);
float ptr_years = ptr_days / 365;
cout<<"The name of the Second Bond is : "<< bond_ptr -> get_name() <<endl;
cout<<"The price of the Second Bond is : "<< bond_ptr -> get_price() << endl;
cout<<"The difference between Maturity Date and Today's Date is: "<<ptr_days<< " Days."<<endl;
cout<<"The difference between Maturity Date and Today's Date is: "<<ptr_years<< " Years."<<endl;
return 0;
}