Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JUST the PackageTreacking.cpp FILE) without adding any other functions how can i complete the rest of the code in my packagetracking.cpp file where it says

(JUST the PackageTreacking.cpp FILE) without adding any other functions how can i complete the rest of the code in my packagetracking.cpp file where it says to be completed JUST THE LAST CPP

*********this is my main*************

include

#include

#include

#include

#include

#include "PackageTracking.h"

#include "ShippingStatus.h"

using namespace std;

template

bool testAnswer(const string &nameOfTest, const T& received, const T& expected);

template

bool testArrays(const string& nameOfTest, const T& received, const T& expected, const int& size);

int main() {

// Test only ShippingStatus class

ShippingStatus testStatus01("Package has left seller facility and is in transit to carrier", "N/A", 1515978000);

testAnswer("testStatus01.m_getLocation() test", testStatus01.m_getLocation(), string("N/A"));

testAnswer("testStatus01.m_getStatus() test", testStatus01.m_getStatus(), string("Package has left seller facility and is in transit to carrier"));

testAnswer("testStatus01.m_getTime() test", testStatus01.m_getTime(), time_t(1515978000));

ShippingStatus testStatus02("Shipment arrived at Amazon facility", "Hebron, KENTUCKY US", 1516111440);

testAnswer("testStatus02.m_getLocation() test", testStatus02.m_getLocation(), string("Hebron, KENTUCKY US"));

testAnswer("testStatus02.m_getStatus() test", testStatus02.m_getStatus(), string("Shipment arrived at Amazon facility"));

testAnswer("testStatus02.m_getTime() test", testStatus02.m_getTime(), time_t(1516111440));

ShippingStatus testStatus03("Shipment arrived at Amazon facility", "San Bernardino, CALIFORNIA US", 1516366740);

testAnswer("testStatus03.m_getLocation() test", testStatus03.m_getLocation(), string("San Bernardino, CALIFORNIA US"));

testAnswer("testStatus03.m_getStatus() test", testStatus03.m_getStatus(), string("Shipment arrived at Amazon facility"));

testAnswer("testStatus03.m_getTime() test", testStatus03.m_getTime(), time_t(1516366740));

// Test PackageTracking class

string tmp_strtrackingnumber;//

tmp_strtrackingnumber = "TBA688567081000";

PackageTracking testPackageTracking(tmp_strtrackingnumber);

testPackageTracking.m_addUpdate(testStatus01.m_getStatus(), testStatus01.m_getLocation(), testStatus01.m_getTime());

testPackageTracking.m_addUpdate(testStatus02.m_getStatus(), testStatus02.m_getLocation(), testStatus02.m_getTime());

testPackageTracking.m_addUpdate(testStatus03.m_getStatus(), testStatus03.m_getLocation(), testStatus03.m_getTime());

testPackageTracking.m_setCurrent(testStatus01.m_getTime());

testAnswer("testPackageTracking.m_getLocation()", testPackageTracking.m_getLocation(), string("N/A"));

testAnswer("testPackageTracking.m_getStatus( )", testPackageTracking.m_getStatus( ), string("Package has left seller facility and is in transit to carrier"));

testPackageTracking.m_setCurrent(testStatus02.m_getTime());

testAnswer("testPackageTracking.m_getLocation()", testPackageTracking.m_getLocation(), string("Hebron, KENTUCKY US"));

testAnswer("testPackageTracking.m_getStatus( )", testPackageTracking.m_getStatus( ), string("Shipment arrived at Amazon facility"));

// Test back and forward

testPackageTracking.m_moveForward();

testAnswer("testPackageTracking.m_moveForward()", testPackageTracking.m_getLocation(), string("San Bernardino, CALIFORNIA US"));

testAnswer("testPackageTracking.m_getStatus( )", testPackageTracking.m_getStatus( ), string("Shipment arrived at Amazon facility"));

testAnswer("testPackageTracking.m_getTime( )", testPackageTracking.m_getTime( ), time_t(1516366740));

testPackageTracking.m_moveBackward();

testAnswer("testPackageTracking.m_moveBackward()", testPackageTracking.m_getLocation(), string("Hebron, KENTUCKY US"));

testAnswer("testPackageTracking.m_getStatus( )", testPackageTracking.m_getStatus( ), string("Shipment arrived at Amazon facility"));

testAnswer("testPackageTracking.m_getTime( )", testPackageTracking.m_getTime( ), time_t(1516111440));

// Test PackageTracking reading from a file

PackageTracking testPackageTracking01(tmp_strtrackingnumber);

string tmp_filename = tmp_strtrackingnumber + ".txt";

if (!testPackageTracking01.m_readTrackingFile(tmp_filename)) {

cout << "Failed to read tracking file" << endl;

return (-1);

}

testAnswer("testPackageTracking01.m_getLocation()", testPackageTracking01.m_getLocation(), string("Chino, US"));

testAnswer("testPackageTracking01.m_getStatus( )", testPackageTracking01.m_getStatus( ), string("Package arrived at a carrier facility"));

testAnswer("testPackageTracking01.m_getTime( )", testPackageTracking01.m_getTime( ), time_t(1516410060));

// Test history printing

cout << " Printing all previous updates: ";

testPackageTracking01.m_printPreviousUpdates();

cout << " Printing all following updates: ";

testPackageTracking01.m_printFollowingUpdates();

cout << " Printing Full History: ";

testPackageTracking01.m_printFullTracking();

//system("pause");

return 1;

}

template

bool testAnswer(const string &nameOfTest, const T& received, const T& expected) {

if (received == expected) {

cout << "PASSED " << nameOfTest << ": expected and received " << received << endl;

return true;

}

cout << "FAILED " << nameOfTest << ": expected " << expected << " but received " << received << endl;

return false;

}

template

bool testArrays(const string& nameOfTest, const T& received, const T& expected, const int& size) {

for(int i = 0; i < size; i++) {

if(received[i] != expected[i]) {

cout << "FAILED " << nameOfTest << ": expected " << expected << " but received " << received << endl;

return false;

}

}

cout << "PASSED " << nameOfTest << ": expected and received matching arrays" << endl;

return true;

}

*********************This is my shippingstatus.h header file ***********************

#ifndef ShippingStatus_h #define ShippingStatus_h

#pragma once

#include using namespace std;

class ShippingStatus { public: ShippingStatus(); ShippingStatus(const string& status, const string& location, const time_t& timeUpdated );

string m_getStatus(); //returns status of shippingStatus string m_getLocation(); //returns location of shipppingStatus time_t m_getTime(); private: string Status; string Location; time_t Timer;

};

#endif /* ShippingStatus_h */

**********************This is my shippingstatus.cpp cpp file *************************

#include "ShippingStatus.h"

//create a constructor ShippingStatus::ShippingStatus() { //to be completed Status = ""; Location = ""; Timer = time(NULL); }

//create a constructor with argument ShippingStatus::ShippingStatus(const string& status, const string& location, const time_t& timeUpdated) { //to be completed Status = status; Location = location; Timer = timeUpdated; }

string ShippingStatus::m_getStatus(){ //to be completed return Status; //return value }

string ShippingStatus::m_getLocation(){ //to be completed return Location; //return value }

time_t ShippingStatus::m_getTime() { //to be completed return Timer; //returns }

**************************This is my packagetracking.h header file********************

#ifndef PackageTracking_h

#define PackageTracking_h

#pragma once

#include

#include

#include

#include

#include

#include

#include "ShippingStatus.h"

using namespace std;

class PackageTracking {

public:

PackageTracking(const string& strnum);

void m_addUpdate( const string& status, const string& location, const time_t& timeUpdated); // add a new update

bool m_moveBackward();//move iterator one step back in time; return false if not possible (true otherwise)

bool m_moveForward();//move iterator one step forward in time; return false if not possible (true otherwise)

string m_getLocation( );//return the location of the current update

time_t m_getTime( );//return the time of the current update

string m_getStatus( );//return the status of the current update

int m_getNumofUpdate() const; // get the total numbers of shipping status updates

bool m_setCurrent(const time_t& timeUpdated);//set current update to given time; return false if time is not found (true otherwise)

void m_printPreviousUpdates(); //print all previous updates in the shipping chain from beginning, all the way up to (but not including) the current update you are viewing (may not be the most recent update).

void m_printFollowingUpdates();//print all updates from the current update you are viewing to the last update in the tracking chain.

void m_printFullTracking();//print all the status updates in the tracking chain.

//read the full tracking chain from a file and follow the commands as specified in the file

//return false if there is an error reading file (true otherwise)

bool m_readTrackingFile(string fileName);

private:

string Location;

string Status;

time_t Timer;

int NumOfUpdate;

};

#endif /* PackageTracking_h */

**********************This is my packagetracking.cpp cpp file******************

#include "PackageTracking.h"

PackageTracking::PackageTracking(const string& strnum) {

//to be completed

}

// add a new update

void PackageTracking::m_addUpdate( const string& status, const string& location, const time_t& timeUpdated){

//to be completed

Status = status;

Location = location;

Timer = timeUpdated;

}

bool PackageTracking::m_moveBackward()//move iterator one step earlier in time

{

//to be completed

}

bool PackageTracking::m_moveForward()//move iterator one step forward in time

{

//to be completed

}

string PackageTracking::m_getLocation( )//return the location of the current update

{

//to be completed

return Location; // return value

}

time_t PackageTracking::m_getTime( )//return the time of the current update

{

//to be completed

return Timer; // return value

}

string PackageTracking::m_getStatus( )//return the status of the current update

{

//to be completed

return Status; //return value

}

int PackageTracking::m_getNumofUpdate() const // get the total numbers of shipping status updates

{

//to be completed

return NumOfUpdate; //return value

}

void PackageTracking::m_printPreviousUpdates() //print all previous updates in the shipping chain when the package was shipped, all the way up to (but not including) the current update you are viewing (may not be the most recent update)

{

//to be completed

}

//print all updates from the current update you are viewing to the last update in the tracking chain

void PackageTracking::m_printFollowingUpdates()

{

//to be completed

}

void PackageTracking::m_printFullTracking()//print all the updates in the tracking chain.

{

//to be completed

}

bool PackageTracking::m_setCurrent(const time_t& timeUpdated)//view an update.

{

//to be completed

}

bool PackageTracking::m_readTrackingFile(string fileName) {

//to be completed

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

List the advantages and disadvantages of the pay programs. page 505

Answered: 1 week ago