Пример #1
0
void Food::description() const
{
	cout << "商品名称: " << getName() << endl;
	cout << "原价: " << getUnitPrice() << endl;
	cout << "折扣价: " << getUnitPrice() * getDiscount() << endl;
	cout << "折扣系数: " << getDiscount() << endl;
	cout << "库存: " << getInventory() << endl;
	cout << "商品详情: " << endl << getDetails() << endl;
}
Пример #2
0
// Function:     processSale
// Inputs:       NA
// Outputs:      NA
// Description:  Calculates totals and taxes.
//
void ContractorSale::processSale()
{
    // Calculate subtotal.
    calculateSubTotal();
    double subtotal = getSubTotal();

    std::cout << SUBTOTAL << subtotal << std::endl;
    std::cout << SALE_CONT << std::endl;
    std::cout << CONT_ID;

    // Prompt for user id.
    getline(std::cin, contractorID);

    int attempts = 0;

    while ( contractorID.compare(OVERIDE) != 0 && (contractorID.length() > MAX_ID_LENGTH || contractorID.length() < MIN_ID_LENGTH || !file.lookupID(contractorID)) )
    {
        attempts++;

        // ID too long
        if ( contractorID.length() > MAX_ID_LENGTH )
        {
            std::cout << ERROR_ID_TOO_LONG << std::endl;
        }
        // ID too short
        else if ( contractorID.length() < MIN_ID_LENGTH )
        {
            std::cout << ERROR_ID_TOO_SHORT << std::endl;
        }
        // ID not found in file
        else if ( !file.lookupID(contractorID) )
        {
            std::cout << ERROR_ID_NOT_FOUND << std::endl;
        }

        // Notify that can overide after 3 attempts.
        if ( attempts > 2 )
        {
            std::cout << CAN_OVERIDE << std::endl;
        }

        // Prompt for user id.
        std::cout << std::endl;
        std::cout << CONT_ID;
        getline(std::cin, contractorID);
    }

    applyDiscount();

    std::cout << DISCOUNT << OPEN_PERC << getDiscount()*100 << CLOSE_PERC << getAmtDiscounted() << std::endl;
    std::cout << SUBTOTAL << getSubTotal() << std::endl;

    calculateTax();
    calculateTotal();

    std::cout << TAX << OPEN_PERC << getTaxRate()*100 << CLOSE_PERC << getTotalTax() << std::endl;
    std::cout << TOTAL_AMT << getTotalAmt() << std::endl;
}