rendered paste body//Name: Nicholas Brinley
//Date: 3/10/08
//Class: 53 A
//Purpose: to make an online shopping cart application, function list.
#include "hw6.h"
void greeting()
{
cout << "Welcome to cletus' online store, where we got everything you need "
<< "however you need it.";
return;
}
int menu()
{
int choice;
cout << "These are the availible items" << endl
<< "1. Yard Couch"
<< "\n2. Cinder Blocks"
<< "\n3. Man's Best Friend"
<< "\n4. Exit and get total"
<< "Please select an option by entering its corresponding number: ";
cin >> choice;
return choice;
}
void couches_order(float & total, const float COST_COUCH, couch & couch_order,
const float OPPOSSUM, float & num_couches, float & couch_total)
{
const int MAX_ITEMS = 5;
float none = 0.0;
cout << "how many couches would you like: ";
cin >> num_couches;
while (num_couches > MAX_ITEMS)
{
cout << "please enter a more reasonable amount: ";
cin >> num_couches;
}
couch_details(couch_order);
couch_total = num_couches * (COST_COUCH +
(couch_order.m_hasResident ? OPPOSSUM : none));
total = total + couch_total;
return;
}
void couch_details(couch & couch_order)
{
couch_order.m_couchWeight = 55;
cout << "Would you like to have oppossums with your couch (+$15.95)"
<< "true or false: ";
cin >> couch_order.m_hasResident;
cout << "Would you like giant_floral_green, horrid-green_plastic, or "
<< "delightful water stains? (please type as displayed)";
cin >>couch_order.m_hasResident;
return;
}
void blocks_order(float & total, const float COST_BLOCK, float & num_blocks,
const float COST_HALFBLOCK, block & block_order,
float & block_total)
{
const int MAX_ITEMS = 10;
float block_cost;
cout << "how many blocks would you like: ";
cin >> num_blocks;
while (num_blocks > MAX_ITEMS)
{
cout << "Please enter a more reasonable amount: ";
cin >> num_blocks;
}
block_total = block_details (block_order, COST_BLOCK, COST_HALFBLOCK);
block_total = num_blocks * block_cost;
total = total + (num_blocks * block_cost);
return;
}
float block_details (block & block_order, const float COST_BLOCK,
const float COST_HALFBLOCK)
{
float block_total;
float block_siz;
float block_condit;
cout << "Would you like the block size to be 'standard' or 'half-size': ";
cin >> block_order.m_blockSize;
while (block_order.m_blockSize != "standard" || "half-size")
{
cout << "Please re-enter choice, 'standard' or 'half-size': ";
cin >> block_order.m_blockSize;
}
cout << "How would you like your blocks, 'new' or 'used': ";
cin >> block_order.m_blockCondition;
while (block_order.m_blockCondition != "new" || "used")
{
cout << "Please re-enter your choice, 'new' or 'used': ";
cin >> block_order.m_blockCondition;
}
block_siz =
(block_order.m_blockSize = "standard" ? COST_BLOCK : COST_HALFBLOCK);
block_condit =
(block_order.m_blockCondition = "used" ? .25 : 1.0);
block_total = block_siz * block_condit
return block_total;
}
void dogs_order(float & total, float COST_DOG, float HOUSETRAINED,
float SKUNKSMELL, dog & dog_order, float & num_dogs,
float & dog_total)
{
const int MAX_ITEMS = 10;
float dog_cost;
while (num_dogs <= MAX_ITEMS)
{
cout << "how many dogs would you like: ";
cin >> num_dogs;
}
dog_cost = dog_details (dog_order, COST_DOG, HOUSETRAINED, SKUNKSMELL);
dog_total = num_dogs * dog_cost;
total = total + (num_dogs * dog_cost);
return;
}
float dog_details(dog& dog_order, const float COST_DOG, const float HOUSETRAINED,
const float SKUNKSMELL)
{
float dog_total;
cout << "How old would you like the dog to be: ";
cin >> dog_order.m_age;
cout << "Would you like the dog house trained, 'true' or 'false': ";
cin >> dog_order.m_houseTrained;
while (dog_order.m_houseTrained != true || false)
{
cout << "Please enter true or false";
cin >> dog_order.m_houseTrained;
}
cout << "What would you like your dog to smell like, 'skunk' or 'pond': ";
cin >> dog_order.m_smell;
while (dog_order.m_smell != "skunk" || "pond")
{
cout << "Please enter 'skunk' or 'pond': ";
cin >> dog_order.m_smell;
}
dog_total = (dog_order.m_houseTrained = true ? HOUSETRAINED : 0) + COST_DOG
+ (dog_order.m_smell = "skunk" ? SKUNKSMELL : 0);
return dog_total;
}
/*
void make_receipt(receipt receipt, const couch couch_order,
const block block_order, const dog dog_order, const short num_couches,
const short num_blocks, const short num_dogs, const float couch_total,
const float block_total, const float dog_total, const float total)
{
cout << "Please Enter your name, use '_' instead of spaces: ";
cin >> receipt.m_name;
receipt.m_couchTotal = num_couches @ $ couch_total;
receipt.m_blockTotal = "num_blocks @ $ block_total";
receipt.m_dogTotal = "num_dogs @ $ dog_total";
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Your Receipt: " << endl
<< "Bill to: " << receipt.m_name << endl
<< receipt.m_couchTotal << endl << receipt.m_blockTotal << endl
<< receipt.m_dogTotal << endl
<< "Total: $" << total
<< "Thanks and come again";
return;
}*/