Question
#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
#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:
};
#endif /* PackageTracking_h */
#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
}
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
}
time_t PackageTracking::m_getTime( )//return the time of the current update
{
//to be completed
}
string PackageTracking::m_getStatus( )//return the status of the current update
{
//to be completed
}
int PackageTracking::m_getNumofUpdate() const // get the total numbers of shipping status updates
{
//to be completed
}
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
}
#ifndef ShippingStatus_h #define ShippingStatus_h
#pragma once
#include
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:
};
#endif /* ShippingStatus_h */
#include "ShippingStatus.h"
ShippingStatus::ShippingStatus() { //to be completed }
ShippingStatus::ShippingStatus(const string& status, const string& location, const time_t& timeUpdated) { //to be completed }
string ShippingStatus::m_getStatus(){ //to be completed }
string ShippingStatus::m_getLocation(){ //to be completed }
time_t ShippingStatus::m_getTime() { //to be completed }
////////////////////////////////////////////////////////////////////////////////
// DO NOT EDIT THIS FILE (except for your own testing)
// CODE WILL BE GRADED USING A MAIN FUNCTION SIMILAR TO THIS
////////////////////////////////////////////////////////////////////////////////
#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;
}
TBA688567081000.txt
new Package has left seller facility and is in transit to carrier;N/A;1515978000 new Shipment arrived at Amazon facility;Hebron, KENTUCKY US;1516111440 new Shipment departed from Amazon facility;Hebron, KENTUCKY US;1516188120 new Shipment arrived at Amazon facility;San Bernardino, CALIFORNIA US;1516366740 new Shipment departed from Amazon facility;San Bernardino, CALIFORNIA US;1516392780 new Package arrived at a carrier facility;Chino, US;1516410060 new Out for delivery;Chino, US;1516441740 new Delivered;Diamond Bar, US;1516468200 back back back back forward forward
CPSC 131 Spring 2018 Project 2: Package Tracking Shipped with AMZL US Tracking ID TBA688567081000 Saturday, January 20 5:10 PM 9:49 AM 1:11 AM 8:13 PM 12:59 PM Delivered Diamond Bar, US Friday, January 19 Out for delivery Chino, US Package arrived at a carrier facility Chino, US 2:49 PM Shipment departed from Amazon facility San Bernardino, CALIFORNIA US Shipment arrived at Amazon facility San Bernarding, CALIFORNIA US Wednesday, January 17 11:22 AM Shipment departed from Amazon facility Hebron, KENTUCKY US Tuesday, January 16 Shipment arrived at Amazon facility Hebron, KENTUCKY US Monday, January 15 Package has left seller facility and is in transit to carrier 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 write C++ code to model package tracking. You can still test your code in a Linux environment: when you sync your code with GitHub it will be automatically built and run and the results emailed to you. See section below on Automated testing. Linux development environment Instructions for working in Linux and submitting your code to get feedback by email (even before the final deadline) are posted here. Automated Testing We are also piloting the use of a continuous integration web service that automatically tests your code and gives real-time feedback. This service is provided courtesy of Travis CI. The Travis service will wait for you to push code to GitHub. After you do, it will try to compile and build your code. It will then send you an email describing the outcome. The email also has a link to a dashboard web page you can view to see a detailed log of what worked, or didn t. This way you can get immediate objective feedback about how well your code is working. We recommend pushing your code to GitHub every time you reach a milestone and would like feedback on your progress. You can check the results of automatic testing on Travis at https://travis-ci.com/ (same login as your github account). Grading Rubric Your grade will be comprised of two parts, Form and Function. Function refers to whether your code works properly as tested by the main function (80%). Form refers to the design, organization, and presentation of your code. An instructor will read your code and evaluate these aspects of your submission (20%). Deadline The project will be submitted in two stages. Stage 1 (Design): The goal in this stage is to form a team, study the problem, and come up with a design to solve the problem. Your design should include: What are the member variables for the classes and their types A drawing of the relation between the objects of the two classes Pseudocode (i.e an informal English outline of the processing steps) of all the member functions Include the above information in a single PDF document and upload to Titanium. Include the names of the team members and their sections. You are encouraged to discuss your design with your instructor. The Stage 1 deadline is Tuesday, March 13, 11:59 pm. This class contains a method to read item information from a text file. m_readTrackingFile() will read the full tracking chain from a file and follow the commands as specified in the file. Hint: use ifstream, istringstream, getline(). om_printPrevious Updates() will print all previous status in the shipping chain when the package was shipped, all the way up to (but not including) the current status that you are viewing. om_printFollowingUpdates() will print all status following the current status that you are viewing (inclusive) to the last status in the tracking chain. om_printFullTracking() will print all the status updates in the tracking chain. Main.cpp: The entry point to the application. The main() function will test the output of your functions. This is already completed but feel free to change it for your own testing (during grading we will use the original main file with more test examples). README.md file. You must edit this file to include the name and CSUF email address of each student in your group. Do this even if you are working by yourself. We need this information so that we can enter your grades into Titanium. For example, if your group includes students Ada Lovelace and Charles Babbage, your README.md should be in this format: Group members: Ada Lovelace adalovelace@csu.fullerton.edu Charles Babbage charlesbab@csu.fullerton.edu Hints Read code comments for more details of function descriptions. Start by implementing the ShippingStatus class, then the Package Tracking class. It can be overwhelming working on the Package Tracking class so start with the constructor, then the m_addUpdate() function, then the m_move Backward()and m_moveForward(functions. Remember the Package Tracking class will include a linked list for the shipping history. It will also need an iterator or pointer to point to a specific status in the linked list. Iterators are very similar to pointers. Both iterators and pointers can be tricky. Make sure you re keeping track of whether you re talking about an address or the object at that address. Remember to use the -> operator! Obtaining and submitting code We will be using GitHub Classroom to distribute the skeleton code and collect your submissions. This requires you to have an account on github.com. If you are new to GitHub, do the following to get started: 1. Create an account at github.com. You may want to use this account to show a portfolio of your work to prospective employers in the future, so choose something professional. 2. Read Understanding the GitHub Flow and Hello World at GitHub Guides. 3. Read the instructions below for your chosen development environment (Visual Studio on Windows/Linux) Once you understand the basic operation of git, click the assignment link to fork your own copy of the skeleton code to your PC. One student from a group clicks on the link below and forms a new team. IMPORTANT: The team name must begin with your single digit section number (1-6). For example: 2-Brians-team. Note that the entire project URL will then be of the form: https://github.com/CSUF-CPSC-131-Spring2018/project2-2-brians-team (the prefix project2- is automatically created). This student then invites his/her project partner as an Outside collaborator in the settings menu. Do not fork your repository to your personal github account (instructors have admin access to private repositories). Your code should have a URL like https://github.com/CSUF-CPSC-131-Spring2018/project2-2-brians-team, NOT https://github.com/brian/project2-2-brians-team. Assignment link: https://classroom.github.com/g/RxqwsYpe (If you get an error when clicking the assignment link, chances are that your repository was still created successfully. Check your github.com page and you will see you are a member of the CSUF-CPSC-131-Spring2018 organization) Here is a video that shows the steps: https://www.youtube.com/watch?v=-52quDR2QSc Then edit your code locally as you develop it. As you make progress, commit and push your changes to your repository regularly. This ensures that your work is backed up, and that you will receive credit for making a submission. Don t wait until the deadline to learn how to push code! Development environment The test platform is Linux with the clang++ -std=c++11 compiler. For this reason, the recommended development platform is Linux. However, you can choose to use a different development environment as long as you produce standards compliant C++ code that builds and runs on the test platform. Windows development environment Instructions for working in Windows with Visual Studio and submitting your code to GitHub (and get feedback by email even before the final deadline) are posted here. (Note that there are other ways of linking your development environment with GitHub using a GUI: SourceTree, GitHub Desktop) You should use only standard-compliant C++11 code. It is your responsibility for ensuring that your code will work in our testing environment. In particular, remember that: File names are case-sensitive in Linux Variables have to be explicitly initialized. Member variables have to be initialized inside the constructors. 4 In addition, when asked, your program should keep track of every shipping status and when it was 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. Package Tracking is where the bulk of your work will be done. Package Tracking 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. You are allowed to use or refer to the following implementations: https://github.com/apanangadan/CSUF-CPSC_131/blob/master/DLinkedList.h https://github.com/kevinwortman/thedatastructures/blob/master/doubly_linked_list.hh https://github.com/kevinwortman/thedatastructures/blob/master/doubly_linked_list_example.cc Your code is tested in the provided main.cpp. Source Code Files You are given skeleton code files with many blank areas. Your assignment is to fill in the missing parts so that the code is complete and works properly when tested. ShippingStatus.h and ShippingStatus.cpp: Stores location and status of the package, as well as when the status was recorded. Package Tracking.h and Package Tracking.cpp: Stores a linked list representation of all the shipping status for a given package.
Step by Step Solution
3.46 Rating (156 Votes )
There are 3 Steps involved in it
Step: 1
The skin friction coefficient Cf for a laminar boundary ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started