Example #1
0
void Exercise6()
{
	Shop_Struct Shop;
	std::string input;

	while (true)
	{
		New("6");
		std::cout << "What would you like to do?" << std::endl << std::endl
			<< "a. Change the price of an item" << std::endl
			<< "b. Buy additional stock for an item" << std::endl
			<< "c. Sell stock to gain more gold" << std::endl
			<< "d. Exit shop" << std::endl << std::endl
			<< "Input: ";
		getline(std::cin, input);

		if ((input == "a")||(input == "a."))
			while (Pricing(Shop)) {}
		if ((input == "b") || (input == "b."))
			while (Buy(Shop)) {}
		if ((input == "c") || (input == "c."))
			while (Sell(Shop)) {}
		if ((input == "d") || (input == "d."))
			break;
	}
}
Example #2
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;
}
Example #3
0
// 全部卖出
void HoldPosition::sellAll(float Price, string StockName, int idx) {
	stockPosition *tmpPosition;
	if (nullptr != (tmpPosition = _checkStockId(StockName))) {
		Sell(Price, tmpPosition->subMount[idx], StockName, idx);
		tmpPosition->subBuyCount[idx] = 0;
		tmpPosition->buyCount = 0;
	}
	showUPorDOWN();
}
//	反手
TradeRecordCollection TradeFacility::Reverse()
{
	int nSlot = m_nPosition.nSlot;
	TradeRecordCollection trs;

	if(nSlot == 0) return trs;

	trs.push_back(Close());

	if(nSlot > 0)
	{
		trs.push_back(Sell(abs(nSlot)));
	}
	else
	{
		trs.push_back(Buy(abs(nSlot)));
	}

	return trs;
}
HRESULT __stdcall Trader::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
	HRESULT hr = S_OK;
	
	switch(dispidMember)
	{
		case 0:
			pVarResult->vt = VT_I4;
			pVarResult->intVal = m_stock;
			break;

		case 1:
			VariantChangeType(&pDispParams->rgvarg[1], &pDispParams->rgvarg[1], 0, VT_I4);
			VariantChangeType(&pDispParams->rgvarg[0], &pDispParams->rgvarg[0], 0, VT_R4);
			hr = Buy(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].fltVal);
			break;

		case 2:
			VariantChangeType(&pDispParams->rgvarg[1], &pDispParams->rgvarg[1], 0, VT_I4);
			VariantChangeType(&pDispParams->rgvarg[0], &pDispParams->rgvarg[0], 0, VT_R4);
			hr = Sell(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].fltVal);
			break;

		case 3:
			pVarResult->vt = VT_I4;
			pVarResult->intVal = m_count;
			break;

		case 4:
			pVarResult->vt = VT_R8;
			pVarResult->dblVal = m_stock * m_rate + m_balance;
			break;

		default:
			hr = DISP_E_MEMBERNOTFOUND;
	}
	
	return hr;
}