Be on schedule. Score better.


Solved! Get answer or ask a different Question 30742

Project 1: TrackerNote: This assignment is used to assess the required outcomes for the course, as outlined in the course syllabus. These outcomes are: use of arrays and pointers in the solution of programming problems using C++ create and use classes within the C++ programming language create, compile, and execute C++ programs within the Unix environment, using the Object-Oriented design model program using C++ techniques: composition of objects, operator overloads, dynamic memory allocation, inheritance and polymorphism, and file I/O program using C++ techniques: composition of objects, templates, preprocessor directives, and basic data structures. These will be assessed using the following rubric: Key: I = ineffective E = effective H = highly effective i. Use Arrays and Pointers – – – ii. Use Classes and Objects – – – iii. OO Programming Techniques – – – iv. Inheritance and Polymorphism – – – In order to earn a course grade of C- or better, the assessment must result in Effective or Highly Effective for each outcome. Educational Objectives: After completing this assignment the student should have the following knowledge, ability, and skills:Define a class hierarchy using inheritance Define a class hierarchy using multiple inheritance Define virtual member functions in a class hierarchy Implement a class hierarchy using inheritance Implement a class hierarchy using multiple inheritance Implement virtual member functions in a class hierarchy Use initialization lists to call parent class constructors for derived class constructors State the call sequence for constructors in an inheritance chain State the call sequence for destructors in an inheritance chain 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: Seven (7) files: vehicles.h, vehicles.cpp, shapes.h, shapes.cpp, verbose.cpp, tracker.cpp, and makefile. The DOT Tracker ProjectThis project simulates an application called tracker for the Department of Transportation (DOT) in which highway traffic data is accumulated in real time using various sensing equipment. The sensors can passively detect a vehicle and actively inquire further data when that vehicle is a truck. For all vehicles a serial number is collected. The serial number can be decoded to determine the vehicle type (car, truck/van, truck/tanker, truck/flatbed), passenger capacity, and, for trucks, the dimensions of its carrier. Trucks actively respond with their DOT license number as well. Tracker is set up at a specific point on a roadway, for example at a toll booth or a specific segment of interstate highway. Once activated, it keeps a running account of the passing vehicles. It can report summary data and also can keep full reports of all vehicles passing the checkpoint within a certain time block. Procedural RequirementsCreate and work within a separate subdirectory cop3330/proj1. Review the COP 3330 rules found in Introduction/Work Rules. Begin by copying the following files from the course directory: into your proj1 directory: proj1/tester.cppproj1/segment0.dataproj1/segment1.dataproj1/segment2.dataproj1/proj1submit.sharea51/tester_s.xarea51/tester_i.xarea51/tester-bad_i.xarea51/tracker_s.xarea51/tracker_i.xThe naming of these files uses the convention that _s and _i are compiled from the same cource code on program (Sun/Solaris) and linprog (Intel/Linux), respectively. The executables are distributed only for your information and experimentation. You will not use these files in your own project. You are to define and implement the following classes: Box, Cylinder, Plane, Vehicle, Car, Truck, Van, Tanker, and Flatbed. File shapes.h should contain the definitions of the classes Box, Cylinder, and Plane. File shapes.cpp should contain the member function implementations for these classes. File vehicles.h should contain the definitions of the classes Vehicle, Car, Truck, Van, Tanker, and Flatbed. File vehicles.cpp should contain the implementations for these classes. File verbose.cpp should contain the verbose versions of the various class implementations (both shapes and vehicles).Create a client program for all of these classes in the file tracker.cpp. Create a makefile for all of the project in the file makefile. Turn in all seven (7) files vehicles.h, vehicles.cpp, shapes.h, shapes.cpp, verbose.cpp, tracker.cpp, and makefile using the submit script. Warning: Submit scripts do not work on the program and linprog servers. Use 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 – Server SideYou are to define and implement the following classes:Boxfloat Volume() const // returns volume of box object float length_, width_, height_Cylinderfloat Volume() const // returns volume of cylinder object float length_, radius_Planefloat Area() const // returns area of plane object float length_, width_Vehicle() const // returns serial number PassengerCapacity () const // returns passenger capacity () const // returns 0() const // returns “UNK”(const char* sn)serialNumber_; unsigned int passengerCapacity_;CarVehicleconst char* ShortName() const // returns “CAR” TruckVehicle () const // returns “TRK”() const // returns the license no char* DOTLicense_; VanTruck , Box () const // returns volume of box () const // returns “VAN”TankerTruck , Cylinder () const // returns volume of cylinder () const // returns “TNK”FlatbedTruck , Plane () const // returns area of plane () const // returns “FLT” Each class should have the following: Default constructor Parametrized constructor that initializes the class variables Destructor Private copy constructor prototype Private assignment operator prototype Follow the notation conventions: Compound names use uppercase letters to separate words likeThis or LikeThis Class, method, and function names begin with upper case letters LikeThis Object and variable names names begin with lower case letters likeThis Class member variables end with underscore likeThis_ Be sure to make exactly the methods virtual that are needed – that is, those that are overridden in derived classes. Do not make a method virtual unless it is needed virtual.During development and testing of the classes, each constructor and destructor should include a line of code that sends an identifying message to standard output. (This requirement serves as a code testing device. These identifying output statements will be removed after development. But leave them in verbose.cpp when you submit!) For example, the Van destructor should output the message “~Van()”. The user-defined type VehicleType is an enumerated type: VehicleTypebadSn, vehicle, car, truck, van, tanker, flatbed The static method VehicleType Vehicle::SnDecode(const char* sn) returns the vehicle type based on the first (index 0) character of the serial number sn according to this table: 6flatbed After your classes have been fully developed and debugged, so they compile without warnings using the commands g++ -c -I. -Wall -Wextra shapes.cpp and g++ -c -I. -Wall -Wextra vehicles.cpp, it is time to test with tester.cpp: Concatenate the files shapes.cpp and vehicles.cpp into the file verbose.cpp [command: cat shapes.cpp vehicles.cpp > verbose.cpp]. Add file documentation to verbose.cpp as usual. #include shapes.h and vehicles.h into verbose.cpp, between your file documentation and the beginning of the code. Make sure that verbose.cpp compiles to object code with our usual compile command g++ -c -Wall -Wextra -I. verbose.cpp. Now compile the executable program tester.x with this command: g++ -otester.x -I. tester.cpp Thoroughly test your vehicle objects with this program. Note that this program prompts you for a serial number. The serial number is decoded to get a vehicle type, and an object of that type is created dynamically. You should see the constructor calls displayed, in correct order, because tester uses the verbose versions of your classes. Then the methods of this object are called. You should see correct serial number (and, for trucks, dot license) displayed. An “OOPS” message will be displayed if a problem is detected with your constructors. Finally the object is deleted, and you should see the destructors called in correct order. Read the source code in tester.cpp both to understand how it works and also for hints on how to do certain things in tracker.cpp. After you have developed and thoroughly tested your Vehicles classes as above, it is time to prepare your classes for Tracker: Comment out the verbose output statements in the constructors and destructors in shapes.cpp and vehicles.cpp, but leave them in verbose.cpp We are now ready to proceed to client side development. Code Requirements and Specifications – Client SideYou are to implement a client program tracker of the vehicle system described above.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 segment If the number is zero, exit For each vehicle in the segment, 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 segment After all the vehicles in the segment have been read and their corresponding objects created, report a summary of the various vehicles by type, along with the total tonnage of the segment. After the summary, report the details: for each vehicle in the segment: Report the vehicle data to screen Release the memory used to store the vehicle When in doubt, use the distributed executables as a guide to output data and formatting. Note that the tracker processing loop continues until zero is read for a segment 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 passenger capacity pc. For all specific truck types, the next entry will be the DOTlicense DOTL followed by the dimension data d1 d2 d3(optional). For example, a car, truck, van, tanker, and flatbed would have these lines of data: sn pcsn pc DOTLsn pc DOTL d1 d2 d3sn pc DOTL d1 d2sn pc DOTL d1 d2The dimensional data should be interpreted in the order d1 = length, d2 = width or radius, d3 = height. Note that this is more or less self-documenting in the data file Note also that we will assume that each vehicle and its data are in a separate line of the input file. Tracker should instantiate the objects of a segment using an array whose elements are of type Vehicle *, that is, pointer to type Vehicle. At the end of reading the segment data, this array should have pointers to vehicle objects representing the entire segment. These objects should exist until the line in the report representing the object is generated. Use declared constants (not hardcoded literal values) for the following: The maximum number of vehicles in a traffic segment (100) The maximum number of characters in a vehicle serial number (20) The maximum number of characters in a truck DOT license (20) Check for a segment 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 <vehicles.h>, 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. Do not submit “verbose” classes for tracker.HintsModel executables tester.x and tracker.x are for your information only – they are not needed for your project. However, tester.cpp is indispensable: This is one of the test programs that will be used to assess your project. Moreover, it will help you debug your classes and gives some example code that can serve as a model for your client tracker program. To execute tester, enter a serial number at the prompt. The first digit determines the vehicle type. Tester uses the verbose implementations, so you should see all of the constructor and destructor calls for the selected type. To execute tracker on a data file use redirection. For example, enter prompt> tracker.x < segment2.datato run tracker.x with the data file as input. All destructors should be declared virtual. Be sure you understand why. There will likely be an exam question related to this. It is wise to develop and test all of the classes prior to working on any code for tracker.cpp. This way you can concentrate on class development – some call this “wearing your server hat”. After you are satisfied that your classes are correct and ready for submission, including all documentation etc, only then do you switch to your “client” hat and start working on tracker. If you were starting from “scratch”, you would first write a test harness like tester.cpp that exercises your classes and allows you to debug them as a system. The program tester.cpp is central to your effort in several ways: It allows you to debug your classes, prior to even thinking about tracker. This way, you are wearing your “server” hat while classes are being created. (One exception: memory management issues may not be exposed by tester.) After the classes are debugged and working correctly, you change to your “client” hat and start working on the tracker program. The file tester.cpp has model code that you should understand in every detail and use as a model for your tracker code. Note: you will likely see code similar to tester on an exam. To compile tester, a command line compile is all that is required, because the source code for the dependent files is included into the client program: prompt> g++ -I. -Wall -Wextra -otester.x tester.cppNote, this is different from the way you should compile tracker, which requires a makefile to manage separate compilation of all the code files. Your classes will be independently tested with client programs written to the interfaces defined above.Run the distributed executables for tester and tracker in LIB/area51/ to see how your programs are expected to behave.

Looking for a Similar Assignment? Our ENL Writers can help. Use the coupon code FIRST15 to get your first order at 15% off!
Students Love Us

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp