Question: The following needs to be in c++ and needs to work with the code at the bottom Project 5: FastLane Tracker Adding the Tracker application

The following needs to be in c++ and needs to work with the code at the bottom

Project 5: FastLane Tracker

Adding the Tracker application to the FastLane project

Revision dated 02/20/17

Educational Objectives: After completing this assignment the student should have the following knowledge, ability, and skills:

Define static (compile time) polymorphism

Define dynamic (run time) polymorphism

Use a class hierarchy to implement dynamic polymorphism

Operational Objectives: Create (define and implement) classes Box, Cylinder, Plane, Vehicle, Car, Truck, Van, Tanker, and Flatbed and an object-oriented vehicle counter for use by the Department of Transportation (DOT).

Deliverables: shapes.h, shapes.cpp, vehicles.h, vehicles.cpp, tracker.cpp, makefile, log.txt

Deliverables Note: This project depends on these files delivered with the previous project: vehicles.h, vehicles.cpp, shapes.h, shapes.cpp

Assessment Rubric

student build: (5 pts) stester.x [0..1]: x vtester.x [0..1]: x tracker.x [0..3]: x project build: (5 pts) build stester.x [0..1]: x build vtester.x [0..1]: x build tracker.x [0..3]: x compatibility of framework: (5 pts) diff shapes.h [0..1]: x diff shapes.cpp [0..1]: x diff vehicles.h [0..1]: x diff vehicles.cpp [0..2]: x project tests: (35 pts) stester.x stester.com [0..5]: x vtester.x vtester.com [0..5]: x tracker.x < shift1.in [0..5]: x tracker.x < shift2.in [0..5]: x tracker.x < shift3.in [0..5]: x tracker.x < shift4.in [0..5]: x tracker.x < shift_wide.in [0..5]: x software engineering: code quality, requirements [-30..0]: ( x) code standards [-10..0]: ( x) dated submission deduction [2 pts per]: ( x) -- total [0..50]: xx 

The FastLane Tracker Project

This project simulates an application called tracker for the Florida Department of Transportation in which data from FastLane transponders is accumulated in real time using various sensing equipment. The sensors detect a FastLane-equiped commercial vehicle (licensed carrier of people or freight) and actively inquire further data from that vehicle. The data is recorded and the vehicle is allowed to proceed without entering the upcoming inspection station, thus saving a great deal of time for both the vehicle operator and the inspection station staff. Of course, there is a one-time inspection required for these vehicles, and electronic guards prevent tampering with inspectable aspects of the vehicle. Data from the one-time inspection is available from a secure cloud database for use by inspectors if required.

For all commercial vehicles the following data is collected:

Vehicle registration number

Operator Identity

Operator Commercial Driver License Number

Additional data is collected depending on the specific type of vehicle:

Carriage, Bus, Limo: passenger capacity

Van: width, length, height

Tanker: radius, length

Flatbed: width, length

Note that operators are not counted in passenger capacity, so that there is a strict divide between carriages, which carry people as passengers, and trucks, which carry freight. A carriage may not carry freight and a truck may not carry passengers.

Tracker is set up adjacent to a DOT inspection station. Once activated, it keeps a running account of the FastLane equipped passing vehicles for a period of time called a "shift". At the end of a shift, tracker reports summary data and also creates a detailed log of each instance of a FastLane interaction during that shift.

The current assignment focusses on the "client side" of the FastLane project. The tracker client program uses the CommercialVehicle framework built in the preceeding assignment.

Procedural Requirements

Create and work within a separate subdirectory cop3330/proj5. Review the COP 3330 rules found in Introduction/Work Rules.

Begin by copying all files from LIB/proj5 into your proj5 directory. You should see at least the following files:

proj5/shift1.in proj5/shift2.in proj5/deliverables.sh 

Also copy area51/tracker_i.x and change its permissions to executable. tracker_i.x is the benchmark executable against which yours will be tested. Note that you can add these lines to your makefile to ensure that you have a current executable benchmark:

tracker_i.x: /home/courses/cop3330p/LIB/area51/tracker_i.x  cp /home/courses/cop3330p/LIB/area51/tracker_i.x .  chmod 700 tracker_i.x . 

(Also add "tracker_i.x" to the dependencies for the first target.)

Begin a log file named log.txt. This should be an ascii text file in cop3330/proj5 with the following header:

log.txt # log file for FastLane project    

This file should document all work done by date and time, including all testing and test results. A free-form section at the end may be used for any other purpose.

Copy the various shapes and vehicles files from the preceeding project: shapes.h, shapes.cpp, vehicles.h, and vehicles.cpp. Be sure that these files remain identical to those from the preceding project. If you need to revise these files, you need to resubmit the previous project. (See rubric above.)

If in the current project you find that the shape and vehicle classes require modification, be sure that you make the modifications in both projects and resubmit the preceding one, so that when we check the requirement above your submissions will pass that check.

Create a client program for all of these classes in the file tracker.cpp.

Turn in the files tracker.cpp and log.txt using the submit script.

Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.

Code Requirements and Specifications - Client Side

You are to implement a client program tracker of the CommercialVehicle framework.

Tracker processes data from a file that is input through redirection and sends results to standard output. (Thus tracker does not deal directly with files but reads from and writes to standard I/O.)

Tracker goes through the following processing loop:

Read the number of vehicles in the next shift

If the number is zero, exit

For each vehicle in the shift,

Decode the vehicle serial number

If other data is needed, read that data

Create a vehicle of the appropriate type using the data read in the previous steps

Update various summary information for this shift

After all the vehicles in the shift have been read and their corresponding objects created, report a summary of the various vehicles by type, along with the total passenger and freight capacity for the segment.

After the summary, report the details in table format: feach vehicle in the shift corresponds to a line in the table.

At the end of the shift, release the memory used to store vehicle objects.

Use the distributed area51 executable as a benchmark for output data and formatting.

Note that the main tracker processing loop continues until zero is read for a shift size. It may be assumed that the file of data is correctly structured so that whenever an appropriate item is expected, it is next in the file. For all vehicles, the data will begin with the serial number sn and then give the remaining information as appropriate. For example, various commercial vehicles would have these lines of data:

reg id cdl <-- vehicle, truck reg id cdl pc <-- carriage, bus, limo reg id cdl width length height <-- van reg id cdl radius length <-- tanker reg id cdl width length <-- flatbed 

(where reg, id, cdl are strings, pc is a non-negative integer, and the dimensions are floats.) The dimensional data should be interpreted in the order as shown (and as in the constructors of the truck types.

Caveate: if reg (the vehicle registration) does not decode to a known vehicle type, all other data on that line should be ignored.

Tracker should instantiate the objects of a shift using an array whose elements are of type Vehicle *, that is, pointer to type Vehicle. At the end of reading the shift data, this array should have pointers to vehicle objects representing the entire shift. These objects should exist until the line in the report representing the object is generated. NOTE: instantiate the objects with the "verbose" variable set to 0 = false (the default).

Use declared constants (not hardcoded literal values) for the following:

The maximum number of vehicles in a traffic shift (100)

The maximum number of characters in an input string [vehicle registration number, operator ID, operator CDL] (50)

Check for a shift size greater than tracker can handle, and exit if that happens. Thus tracker would exit if either size 0 is read or some size greater than the declared constant 6.i above.

Your tracker.cpp source file should #include , but not any of the other project files. Your makefile should create separate object files vehicles.o, shapes.o , and tracker.o and then create the executable tracker.x.

Your tracker project will be tested using the classes that you have previously submitted for the previous project. If you need to revise those, you will need to submit the revisions for that project prior to submitting this project.

Hints

Model executable tracker.x is for your information only - it is not needed for your project.

To execute tracker on a data file use redirection. For example, enter prompt> tracker.x < shift2.in to run tracker.x with the data file shift2.in as input.

Run the distributed executables for tester and tracker in LIB/area51/ to see how your programs are expected to behave.

Code that it needs to work with

vehicles.h

#ifndef VEHICLES_H #define VEHICLES_H #include #include #include #include "shapes.h"

enum VehicleType { badReg=0, vehicle=1, carriage=2, bus=3, limo=4, truck=5, van=6, tanker=7, flatbed=8 };

class CommercialVehicle { public : CommercialVehicle(); CommercialVehicle(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB=0); virtual ~CommercialVehicle(); const char* Registration () const; // returns vehicle registration number const char* Operator () const; // returns operator ID const char* CDL () const; // returns operator CDL virtual unsigned int PassengerCapacity () const; // returns passenger capacity virtual float LoadCapacity () const; // returns volume or area of cargo space virtual const char* ShortName () const; // returns "UNK" static VehicleType RegDecode (const char* sn); private : char* vehicleRegistration_; char* operatorID_; char* operatorCDL_; unsigned short passengerCapacity_; CommercialVehicle(const CommercialVehicle& v); CommercialVehicle& operator=(const CommercialVehicle& v);

protected: bool verbose_; // default value 0 given in constructor prototype };

class Carriage: public CommercialVehicle //Inherits from: CommercialVehicle { public: Carriage(); Carriage(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB); virtual ~Carriage(); const char* ShortName() const; // returns "CAR"

private: Carriage(const Carriage& c); Carriage& operator=(const Carriage& x); };

class Bus: public Carriage //Inherits from: Carriage { public: Bus(); Bus(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB); virtual ~Bus(); const char* ShortName() const; // returns "BUS"

private: Bus(const Bus& b); Bus& operator=(const Bus& x); };

class Limo: public Carriage //Inherits from: Carriage { public: Limo(); Limo(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB); virtual ~Limo(); const char* ShortName() const; // returns "LIM"

private: Limo(const Limo& l); Limo& operator=(const Limo& x); };

class Truck: public CommercialVehicle { public: Truck(); Truck(const char* VR, const char* OI, const char* OC, bool VB); virtual ~Truck(); const char* ShortName() const; // returns "TRK"

private: Truck(const Truck& t); Truck& operator=(const Truck& x); };

class Van: public Truck, Box //Inherits from: Truck and Box { public: Van(); Van(const char* VR, const char* OI, const char* OC, float x, float y, float z, bool VB); virtual ~Van(); float LoadCapacity() const; // returns volume of box const char* ShortName() const; // returns "VAN"

private: Van(const Van& v); Van& operator=(const Van& x); };

class Tanker: public Truck, Cylinder //Inherits from: Truck and Cylinder { public: Tanker(); Tanker(const char* VR, const char* OI, const char* OC, float x, float z, bool VB); virtual ~Tanker(); float LoadCapacity() const; // returns volume of cylinder const char* ShortName() const; // returns "TNK"

private: Tanker(const Tanker& v); Tanker& operator=(const Tanker& x);

};

class Flatbed: public Truck, Rectangle //Inherits from: Truck and rectangle { public: Flatbed(); Flatbed(const char* VR, const char* OI, const char* OC, float x, float z, bool VB); virtual ~Flatbed(); float LoadCapacity() const; // returns volume of rectangle const char* ShortName() const; // returns "FLT"

private: Flatbed(const Flatbed& f); Flatbed& operator=(const Flatbed& x);

}; #endif

vehicles.cpp

#include "shapes.h" #include "vehicles.h" #include #include #include

//CommerciaVehicle****************************************************************************************

const char* CommercialVehicle::Registration () const{ return vehicleRegistration_;} const char* CommercialVehicle::Operator () const{ return operatorID_;} const char* CommercialVehicle::CDL () const{ return operatorCDL_;} unsigned int CommercialVehicle::PassengerCapacity () const{ return passengerCapacity_;} float CommercialVehicle::LoadCapacity () const{ return 0;} const char* CommercialVehicle::ShortName () const{ return "UNK";} VehicleType CommercialVehicle::RegDecode (const char* sn){ VehicleType a; switch (sn[0]){ case '0': a=badReg; break; case '1': a=vehicle; break; case '2': a=carriage; break; case '3': a=bus; break; case '4': a=limo; break; case '5': a=truck; break; case '6': a=van; break; case '7': a=tanker; break; case '8': a=flatbed; break; default: return carriage; } return a; } CommercialVehicle::CommercialVehicle(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB){ verbose_= VB; vehicleRegistration_= new char[1]; std::strcpy (vehicleRegistration_, VR); operatorID_= new char[6]; std::strcpy (operatorID_, OI); operatorCDL_= new char[7]; std::strcpy (operatorCDL_, OC); passengerCapacity_=PC; if(verbose_==1){std::cout<<"Commercial Vehicle("<

//Carriage**********************************************************************************************************

const char* Carriage::ShortName() const {return "CAR";} Carriage::Carriage(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB):CommercialVehicle(VR, OI, OC, PC, VB){ if(CommercialVehicle::verbose_==1){std::cout<<"Carriage("<

//Bus***************************************************************************************************************

const char* Bus::ShortName() const{return "BUS";}

Bus::Bus(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB):Carriage(VR, OI, OC, PC, VB){ if(CommercialVehicle::verbose_==1){std::cout<<"Bus("<

Bus::~Bus(){ if(CommercialVehicle::verbose_==1){ std::cout<<"~Bus()" << ' '; } }

//Limo***************************************************************************************************************

const char* Limo::ShortName() const{return "LIM";} Limo::Limo(const char* VR, const char* OI, const char* OC, unsigned short PC, bool VB):Carriage(VR, OI, OC, PC, VB){ if(CommercialVehicle::verbose_==1){std::cout<<"Limo("<

//Truck***************************************************************************************************************

const char* Truck::ShortName() const{return "TRK";} Truck::Truck(const char* VR, const char* OI, const char* OC, bool VB):CommercialVehicle(VR, OI, OC, 0, VB){ if(CommercialVehicle::verbose_==1){std::cout<<"Truck("<

//Van***************************************************************************************************************

const char* Van::ShortName() const{return "VAN";} float Van::LoadCapacity() const{return Box::Volume();} Van::Van(const char* VR, const char* OI, const char* OC, float x, float y, float z, bool VB):Truck(VR, OI, OC, VB),Box(x,y,z,VB){ x_=x; y_=y; z_=z; if(Truck::verbose_==1){std::cout<<"Van("<

//Tanker***************************************************************************************************************

const char* Tanker::ShortName() const{return "TNK";} float Tanker::LoadCapacity() const{return Cylinder::Volume();} Tanker::Tanker(const char* VR, const char* OI, const char* OC, float x, float y, bool VB):Truck(VR, OI, OC, VB),Cylinder(x,y, VB){ x_=x; y_=y; if(Truck::verbose_==1){std::cout<<"Tanker("<

//Flatbed***************************************************************************************************************

const char* Flatbed::ShortName() const{return "FLT";} float Flatbed::LoadCapacity() const{return Rectangle::Area();} Flatbed::Flatbed(const char* VR, const char* OI, const char* OC, float x, float z, bool VB):Truck(VR, OI, OC, VB),Rectangle(x,z,VB){ x_=x; z_=z; if(Truck::verbose_==1){std::cout<<"Flatbed("<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!