Question
Pseudocode+drawing The goal in this stage is study the problem, and come up with a design to solve the problem. Your design should include: What
Pseudocode+drawing
The goal in this stage is 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
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.
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.
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.
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.
PackageTracking.h and PackageTracking.cpp: Stores a linked list representation of all the shipping status for a given package.
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().
m_printPreviousUpdates() 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.
m_printFollowingUpdates() will print all status following the current status that you are viewing (inclusive) to the last status in the tracking chain.
m_printFullTracking() will print all the status updates in the tracking chain.
Hints
Read code comments for more details of function descriptions.
Start by implementing the ShippingStatus class, then the PackageTracking class. It can be overwhelming working on the PackageTracking class so start with the constructor, then the m_addUpdate() function, then the m_moveBackward()and m_moveForward()functions.
Remember the PackageTracking 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 youre keeping track of whether youre talking about an address or the object at that address. Remember to use the -> operator!
Given code:
#pragma once | |
#include | |
using namespace std; | |
template | |
template | |
class DNode { // doubly linked list node | |
private: | |
E elem; // node element value | |
DNode | |
DNode | |
friend class DLinkedList | |
}; | |
template | |
class DLinkedList { // a doubly linked list | |
public: | |
DLinkedList(); // empty list constructor | |
~DLinkedList(); // destructor | |
bool empty() const; // is list empty? | |
E& front(); // get front element | |
E& back(); // get back element | |
void addFront(const E& e); // add to front of list | |
void addBack(const E& e); // add to back of list | |
void removeFront(); // remove from front | |
void removeBack(); // remove from back | |
int size() const; // list size | |
private: // local type definitions | |
int n; // number of items | |
DNode | |
DNode | |
protected: | |
void add(DNode | |
void remove(DNode | |
}; | |
template | |
DLinkedList | |
n = 0; // initially empty | |
header = new DNode | |
trailer = new DNode | |
header->next = trailer; // have them point to each other | |
trailer->prev = header; | |
} | |
template | |
bool DLinkedList | |
{ | |
return (header->next == trailer); | |
} | |
template | |
E& DLinkedList | |
{ | |
if (empty()) throw length_error("empty list"); | |
return header->next->elem; | |
} | |
template | |
E& DLinkedList | |
{ | |
if (empty()) throw length_error("empty list"); | |
return trailer->prev->elem; | |
} | |
template | |
DLinkedList | |
while (!empty()) removeFront(); // remove all but sentinels | |
delete header; // remove the sentinels | |
delete trailer; | |
} | |
template | |
void DLinkedList | |
DNode | |
u->elem = e; | |
u->next = v; // link u in between v | |
u->prev = v->prev; // ...and v->prev | |
v->prev->next = u; | |
v->prev = u; | |
n++; | |
} | |
template | |
void DLinkedList | |
{ | |
add(header->next, e); | |
} | |
template | |
void DLinkedList | |
{ | |
add(trailer, e); | |
} | |
template | |
void DLinkedList | |
DNode | |
DNode | |
u->next = w; // unlink v from list | |
w->prev = u; | |
delete v; | |
n--; | |
} | |
template | |
void DLinkedList | |
{ | |
if (empty()) throw length_error("empty list"); | |
remove(header->next); | |
} | |
template | |
void DLinkedList | |
{ | |
if (empty()) throw length_error("empty list"); | |
remove(trailer->prev); | |
} | |
template | |
int DLinkedList | |
return n; | |
} |
Shipped with AMZL US Tracking ID TBA688567081000 Saturday, January 20 5:10 PM Delivered Diamond Bor, US 9:49 AM Out for delivery Chino, US 1:11 AM Package arrived at a carrier facility Chino, US Friday, January 19 813 PM Shipment departed from Amazon facility Son Bernarding, CALIFORNIA US hipment arrived at Amazon facility Son Bernardina, CALIFORNIA US 12:59 PM 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 2:49 PM Monday, January 15 Package has left seller facility and is in transit to carrier Shipped with AMZL US Tracking ID TBA688567081000 Saturday, January 20 5:10 PM Delivered Diamond Bor, US 9:49 AM Out for delivery Chino, US 1:11 AM Package arrived at a carrier facility Chino, US Friday, January 19 813 PM Shipment departed from Amazon facility Son Bernarding, CALIFORNIA US hipment arrived at Amazon facility Son Bernardina, CALIFORNIA US 12:59 PM 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 2:49 PM Monday, January 15 Package has left seller facility and is in transit to carrier
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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