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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
#include "PackageInventory.h"
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
PackageInventory::PackageInventory()
{}
void PackageInventory::CreateNewPackage(string senderN, string senderA, string senderC, string senderS, long senderZIP, string recipN, string recipA, string recipC, string recipS, \
long recipZIP, string L, string D, double W, double C, string insure)
{
Package P(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D, W, C, insure);
packages.push_back(P);
for(int i=0; i<packages.size(); i++)
{
cout << packages[i].getSenderName();
}
//packages[i].print();
// packages.push_back(Package(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D, insure, W, C));
}
void PackageInventory::CreateNewExpress(string senderN, string senderA, string senderC, string senderS, long senderZIP, string recipN, string recipA, string recipC, string recipS, \
long recipZIP,string L, string D, double W, double C,string insure, double express )
{
ExpressPackage EP(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP,L , D, W,C, insure, express);
expressPackages.push_back(EP);
// expressPackages.push_back(ExpressPackage(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D, insure, W, C, express));
}
void PackageInventory::CreateNewPriority(string senderN, string senderA, string senderC, string senderS, long senderZIP, string recipN, string recipA, string recipC, string recipS,\
long recipZIP, string L, string D, double W, double C, string insure,string t, double len, double wid, double hie )
{
PriorityPackage PI(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D, W, C, insure, t, len, wid, hie );
priorityPackages.push_back(PI);
}
void PackageInventory::CreateNewInternational(string senderN, string senderA, string senderC, string senderS, long senderZIP, string recipN, string recipA, string recipC, string re\
cipS, long recipZIP,string L, string D, double W, double C, string insure, string count)
{
InternationalPackage IP(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP,L, D, W, C, insure, count);
internationalPackages.push_back(IP);
}
void PackageInventory::PrintAllPackages()
{
if(packages.empty())
cout<<"There are no Packages"<<endl;
else
cout <<"\nPackages: ";
cout << packages.size() << endl;
for(int i=0; i<packages.size(); i++)
{
packages[i].printPackage();
cout <<endl;
}
}
void PackageInventory::PrintAllPriorityPackages()
{
if(packages.empty())
cout<<"There are no Packages"<<endl;
else
cout <<"\nPackages: ";
cout << packages.size() << endl;
for(int i=0; i<packages.size(); i++)
{
packages[i].printPackage();
cout <<endl;
}
}
void PackageInventory::PrintAllPriorityPackages()
{
if(priorityPackages.empty())
cout <<"There are no Priority Packages\n";
else
cout <<"\nPriority Packages: ";
for(int i=0; i<priorityPackages.size(); i++)
{
priorityPackages[i].printPriority();
cout <<endl;
}
}
void PackageInventory::PrintAllExpressPackages()
{
if(expressPackages.empty())
cout <<"There are no Express Packages\n";
else
cout <<"Express Packages";
for(int i=0; i<priorityPackages.size(); i++)
{
expressPackages[i].printExpress();
cout <<endl;
}
}
void PackageInventory::PrintAllInternationalPackages()
{
if(internationalPackages.empty())
cout << "There are no International Packages\n";
else
cout << "\nInternational Package(s): ";
for(int i=0; i <internationalPackages.size(); i++)
{
internationalPackages[i].printInternational();
cout <<endl;
}
}
void PackageInventory::PrintAllShippedOnYear(string D)
{
cout << "\nPackages Shipped on Specific Year: ";
for (int i=0; i< packages.size(); i++)
{
if(D==packages[i].getDate())
{
packages[i].printPackage();
cout <<endl;
}
}
}
void PackageInventory::CalculateTotalCost()
{
}
void PackageInventory::ProcessTransactionFile(string fileName)
{
ifstream inputFile;
string command;
string senderN, senderA, senderC, senderS,recipN, recipA, recipC, recipS, L, D, insure, t, count;
long senderZIP, recipZIP;
double W,C, wid, len, hie, express;
inputFile.open(fileName.c_str());
if(!inputFile)
cout <<"Error opening the transaction file.\n";
else
{
while(inputFile >>command)
{
// cout <<command << endl;
if (command== "CreateNewPackage")
{
inputFile>>senderN >> senderA>> senderC >> senderS >> senderZIP >> recipN >> recipA >> recipC >> recipS>> recipZIP>> L >> D >> W>> C>>insure;
CreateNewPackage(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D,W,C, insure);
}
else if(command=="CreateNewExpress")
{
inputFile >> senderN >> senderA >> senderC >> senderS >> senderZIP >> recipN >> recipA >> recipC >> recipS >> recipZIP >> L >> D >> W>>C>>insure>> express;
CreateNewExpress(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP,L , D, W,C, insure, express);
}
else if(command=="CreateNewPriority")
{
inputFile >>senderN >> senderA >> senderC >> senderS >> senderZIP >> recipN >> recipA >> recipC >> recipS >> recipZIP >> L >> D >> W >> C>> insure >> t >>len >> wid >\
> hie;
CreateNewPriority(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP, L, D, W, C, insure, t, len, wid, hie );
}
else if(command=="CreateNewInternational")
{
inputFile >>senderN >> senderA >> senderC >> senderS >> senderZIP >> recipN >> recipA >> recipC >> recipS >> recipZIP >> L >> D >> W >> C >> insure>>count;
CreateNewInternational(senderN, senderA, senderC, senderS, senderZIP, recipN, recipA, recipC, recipS, recipZIP,L, D, W, C,insure, count);
}
else if(command=="PrintAllPackages")
{
PrintAllPackages();
cout << endl;
}
else if (command=="PrintAllPriorityPackages")
{
PrintAllPriorityPackages();
cout <<endl;
}
else if(command == "PrintAllExpressPackages")
{
PrintAllExpressPackages();
cout <<endl;
}
else if (command=="PrintAllInternationalPackages")
{
PrintAllInternationalPackages();
cout <<endl;
}
else if(command=="PrintAllShippedOnYear")
{
inputFile >>D;
PrintAllShippedOnYear(D);
cout <<endl;
}
else if(command== "CalculateTotalCost")
{
}
}
inputFile.close();
}
}
| |