1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include "Package.h"
#include <iostream>
#include <string>
using namespace std;
Package::Package()
{
weight = 0.0, cost = 0.0;
// strings do not absolutely require initialization, including this for compelteness
senderName = "", senderAddress = "", senderCity = "", senderState = "";
recipientName = "", recipientAddress = "", recipientCity = "", recipientState = "";
// changed Zip from int to string. Int was dropping zeros in zip codes starting with zero.
senderZip = "", recipientZip = "";
}
double Package::getWeight() const
{
double weight = 17;
return weight;
}
double Package::getCost() const
{
double cost = .25;
return cost;
}
double Package::calculateCost()
{
return getWeight() * getCost();
}
void Package::printPackage1() const
{
cout << "Package 1" << endl << endl;
cout << "Sender:" << endl;
cout << "Lou Brown" << endl;
cout << "1 Main St" << endl;
cout << "Boston, MA 11111" << endl << endl;
cout << "Recipient:" << endl;
cout << "Mary Smith" << endl;
cout << "7 Elm St " << endl;
cout << "New York, NY 22222" << endl << endl;
}
void Package::printPackage2() const
{
cout << "Package 2" << endl << endl;
cout << "Sender:" << endl;
cout << "Lisa Klein" << endl;
cout << "5 Broadway" << endl;
cout << "Somerville, MA 33333" << endl << endl;
cout << "Recipient:" << endl;
cout << "Bob George" << endl;
cout << "21 Pine Rd" << endl;
cout << "Cambridge, MA 44444" << endl << endl;
}
void Package::printPackage3() const
{
cout << "Package 3" << endl << endl;
cout << "Sender:" << endl;
cout << "Ed Lewis " << endl;
cout << "2 Oak St" << endl;
cout << "Boston, MA 55555" << endl << endl;
cout << "Recipient:" << endl;
cout << "Don Kelly" << endl;
cout << "9 Main St" << endl;
cout << "Denver, CO 66666" << endl << endl;
}
|