This is the source file for the Cleaners3 project

Header File: Order.h

#if !defined CLEANINGORDER_H_

#define CLEANINGORDER_H_



class CleaningOrder

{

public:

	CleaningOrder();

	CleaningOrder(int s, int p, int o);

	~CleaningOrder();



private:

	int    NumberOfShirts;

	int    NumberOfPants;

	int    NumberOfOtherItems;

	double PriceShirt;

	double PricePants;



public:

	void setNumberOfShirts(const int n);

	int  getNumberOfShirts() const;

	void setNumberOfPants(const int n);

	int  getNumberOfPants() const;

	void setNumberOfOtherItems(const int n);

	int  getNumberOfOtherItems() const;



	void   setPriceShirt(const double p) { PriceShirt = p; }

	double getPriceShirt() const { return PriceShirt; }

	void   setPricePants(const double p) { PricePants = p; }

	double getPricePants() const { return PricePants; }



	double TotalOtherItems;



	double CalcPriceShirts() const;

	double CalcPricePants() const;

	void   CalcPriceOtherItems(int n);

	double CalcTotalOrder() const;

};



#endif // CLEANINGORDER_H_

Source File: Order.cpp

#include <iostream>

#include <iomanip>

using namespace std;



#include "Orders.h"



CleaningOrder::CleaningOrder()

	: NumberOfShirts(0), NumberOfPants(0),

	  NumberOfOtherItems(0), PriceShirt(0.95),

	  PricePants(1.75)

{

}



CleaningOrder::CleaningOrder(int Shirts, int Pants, int Others)

	: NumberOfShirts(Shirts), NumberOfPants(Pants),

	  NumberOfOtherItems(Others), PriceShirt(0.95),

	  PricePants(1.75)

{

}



CleaningOrder::~CleaningOrder()

{

}



void CleaningOrder::setNumberOfShirts(const int n)

{

	NumberOfShirts = (n <= 0 ) ? 0 : n;

}



int  CleaningOrder::getNumberOfShirts() const

{

	return (NumberOfShirts <= 0 ? 0.00 : NumberOfShirts);

}



void CleaningOrder::setNumberOfPants(const int n)

{

	NumberOfPants = (n <= 0) ? 0 : n;

}



int  CleaningOrder::getNumberOfPants() const

{

	return (NumberOfPants <= 0 ? 0.00 : NumberOfPants);

}



void CleaningOrder::setNumberOfOtherItems(const int n)

{

	NumberOfOtherItems = (n <= 0 ? 0 : n); 

}



int  CleaningOrder::getNumberOfOtherItems() const

{

	return (NumberOfOtherItems <= 0 ? 0.00 : NumberOfOtherItems);

}



double CleaningOrder::CalcPriceShirts() const

{

	return NumberOfShirts * PriceShirt;

}



double CleaningOrder::CalcPricePants() const

{

	return NumberOfPants * PricePants;

}



void CleaningOrder::CalcPriceOtherItems(int n)

{

	if( n > 0 )

	{

		double Sum = 0, P;

		

		cout << "\nEnter the price for each misc item\n";

		for(int i = 0; i < n; ++i)

		{

			cout << "Price for item " << i + 1 << ": $";

			cin >> P;

			Sum += P;

		}

		TotalOtherItems = Sum;

	}

	else

		TotalOtherItems = 0.00;

}



double CleaningOrder::CalcTotalOrder() const

{

	return CalcPriceShirts() + CalcPricePants() + TotalOtherItems;

}

Source File: Main.cpp

#include <iostream>

#include <iomanip>

using namespace std;



#include "Orders.h"



void ProcessOrder(CleaningOrder Order[], const int Count)

{

	int QtyShirts, QtyPants, QtyOthers;



	for(int i = 0; i < Count; ++i)

	{

		cout << "\nOrder No. " << i + 1;

		cout << "\nHow many shirts? ";

		cin >> QtyShirts;

		cout << "How many Pants? ";

		cin >> QtyPants;

		cout << "How many other items? ";

		cin >> QtyOthers;



		Order[i].CalcPriceOtherItems(QtyOthers);

		Order[i].setNumberOfShirts(QtyShirts);

		Order[i].setNumberOfPants(QtyPants);

		Order[i].setNumberOfOtherItems(QtyOthers);

		Order[i].setPriceShirt(0.95);

		Order[i].setPricePants(1.75);

	}

}



int main()

{

	const int Counter = 3;

	CleaningOrder Order[Counter];

	void DisplayAnOrder(const CleaningOrder o[], const int x);



	cout << "Since you are in training, I am going to process "

	     << "three orders and let you watch\n";



	ProcessOrder(Order, Counter);

	DisplayAnOrder(Order, Counter);



	cout << "\n\nNext, it's your turn. Let me know when you're ready\n\n";

	return 0;

}



void DisplayAnOrder(const CleaningOrder Order[], const int n)

{

	cout << setiosflags(ios::fixed) << setprecision(2);



	for(int i = 0; i < n; ++i)

	{

	    cout << "\n\nOrder No. " << i + 1;

	    cout << "\n\nCleaning Receipt";

	    cout << "\n======================================="

                 << "\nGeorgetown Cleaning Services - Receipt"

	         << "\n---------------------------------------"

	         << "\nQty\tItem\tUnit\tSub-Total"

	         << "\n" << Order[i].getNumberOfShirts() << "\tShirts\t$"

	         << Order[i].getPriceShirt() << "\t$" << Order[i].CalcPriceShirts()

	         << "\n" << Order[i].getNumberOfPants() << "\tPants\t$"

	         << Order[i].getPricePants() << "\t$" << Order[i].CalcPricePants()

	         << "\n" << Order[i].getNumberOfOtherItems() << "\tOthers\t"

	         << "Vary\t$" << Order[i].TotalOtherItems

	         << "\n---------------------------------------"

                 << "\nTotal Order: $" << Order[i].CalcTotalOrder()

	         << "\n======================================";

	}

}