Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The shippingStatus class is done just need help filling out the packageTracking class I dont know why the m_getLocation() and m_getStatus() is not passing the

image text in transcribed

The shippingStatus class is done just need help filling out the packageTracking class I dont know why the m_getLocation() and m_getStatus() is not passing the tests that are given in the main.cpp when you run the code. this is what i have

//shippingStatus.h

#ifndef ShippingStatus_h #define ShippingStatus_h

#pragma once

#include // need this for time_t for timmer #include using namespace std;

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

string m_getStatus(); string m_getLocation(); time_t m_getTime();

private: //setting getTime() to timer time_t timer; //setting getStatus() to Statu_s string Statu_s; //setting getLocation() to Lo_cation string Lo_cation; };

#endif

//shippingStatus.cpp

#include "ShippingStatus.h"

ShippingStatus::ShippingStatus() { // Setting Stau_s to nothing in it Statu_s = ""; // Setting timer to null which has nothing in it timer = time(NULL); // setting location to nothing Lo_cation = ""; }

ShippingStatus::ShippingStatus(const string& status, const string& location, const time_t& timeUpdated) { // setting these to the parameters given Statu_s = status; Lo_cation = location; timer = timeUpdated; }

string ShippingStatus::m_getStatus() { // returning the Statu_s for getStatus() return Statu_s; }

string ShippingStatus::m_getLocation() { // returning the Lo_cation for getLocation() return Lo_cation; }

time_t ShippingStatus::m_getTime() { // returning timer for getTime() return timer; }

//packageTracking.h

#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

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

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

private:

time_t newTimer; string newStatu_s; string newLo_cation;

};

#endif

//packageTracking.cpp

#include "PackageTracking.h"

PackageTracking::PackageTracking(const string& strnum) { newStatu_s = strnum; newLo_cation = strnum;

}

// add a new update void PackageTracking::m_addUpdate(const string& status, const string& location, const time_t& timeUpdated) { newStatu_s = status; newLo_cation = location; newTimer = timeUpdated; }

string PackageTracking::m_getLocation()//return the location of the current update { return newLo_cation; }

time_t PackageTracking::m_getTime()//return the time of the current update { return newTimer; }

string PackageTracking::m_getStatus()//return the status of the current update { return newStatu_s; }

bool PackageTracking::m_setCurrent(const time_t& timeUpdated)//view an update. { return timeUpdated; }

//main.cpp

#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"));

system("pause"); return 1; }

template bool testAnswer(const string &nameOfTest, const T& received, const T& expected) { if (received == expected) { cout

template bool testArrays(const string& nameOfTest, const T& received, const T& expected, const int& size) { for (int i = 0; i

cout Introduction Modern shipping companies keep track of the location of time sensitive deliveries. Tracking numbers are numbers given to packages when they are shipped. Both senders and receivers can use tracking numbers to view most recent shipping status and trace back to previous status, as shown in the picture above. The first status comes from the company shipping the package. In the example shown in the picture, the first status is "Package has left seller facility and is in transit to carrier". The other statuses are scans at various distribution points within the shipper's system. In this project you will to model package tracking. In addition, when asked, your program should keep track of every shipping status and when it updated. Since we do not know how many updates the shipping will have, we will have a Linked List that will keep track of every status. You are given a simple text file containing actions: back, forward, or new. If the action is listed as new, the next line contains three items, time, location and status, separated by semicolon. See TBA688567081000.txt file for more details. TBA688567081000.txt shows you the example same as in the picture. You are to simulate package tracking based on this text file. Objective You are given partial implementations of two classes. ShippingStatus is a class that holds shipping status including location and status of the package, as well as when the status was recorded. The time visited is the number of seconds from the UNIX epoch, 00:00 Jan 1, 1970 UTC. C++ has a variable type that can handle this, named time t. PackageTracking is where the bulk of your work will be done. PackageTracking stores a linked list representation of all the status. It will be able to read the history from a text file. The text file will have 3 basic commands: new, back, and forward. Back and forward will allow users to view the previous status and the next status of a package. New will provide a newly updated status. You are to complete the implementations of these classes, adding public/private member variables and functions as needed. You are allowed to use the C++ Standard Library containers (such as std::list, and std::list::iterator) for this project

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions