Inheritance. Not really sure were to start on this. Please help!

must create a program that includes user interaction and employs, Object Oriented Programming and Inheritance, File Handling Classes, and some type of data object: Arrays, Linked Lists, Binary Trees or Stacks and Queues. The program must allow the user to enter at least one data item, and then, the program must perform some sort of a calculation or manipulation, and display the result. In addition, the program must allow the user to write data created to a file, and allow for the display of data read from a file. Anything is allowable, as long as it includes input, the techniques from the course and display and file operations.

I want to create a program that reads the data within the PRN file below and sorts the numbers into classes of different types of vehicles and writes it to a new file. On top of that, I must add the counter number (6 digit #), the direction (North, east, south, west), and the name of the county.

01 1115//start time 050916//start date 1045//end time 051316//end date 0015//interval in minutes 02 2 100 766 200

0000 0000 0000 0000 0000 0000 0000 0000 0000 01000000

' ' '0437

02 15 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 /* each one of these numbers is a vehicle class 0001)motor 0002)car trailer 0003)TwoAxleLong 0004)Buses 0005)TwoAxleSixTire 0006)ThreeAxleSingle 0007)FourAxleDouble 0008-0009)FiveAxleDouble 0010)SixAxle double 0011-0012)SixAxleMulti 0013)Bicycle 0014) Not Classified

01 02 0001 0002

00 00

01 01 0 1115 0000 0003 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1115 0000 0000 0003 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001

01 01 0 1130 0000 0004 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1130 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1145 0000 0001 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1145 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000

01 01 0 1200 0000 0001 0002 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1200 0000 0005 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1215 0000 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1215 0000 0005 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1230 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1230 0000 0001 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1245 0000 0004 0001 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000

01 02 1 1245 0000 0007 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1300 0000 0000 0002 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1300 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1315 0000 0004 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1315 0000 0004 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1330 0001 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1330 0000 0004 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1345 0000 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1345 0000 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1400 0000 0001 0003 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1400 0000 0006 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1415 0000 0002 0003 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1415 0000 0002 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1430 0000 0002 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1430 0000 0002 0001 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 01 0 1445 0000 0001 0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

01 02 1 1445 0000 0012 0003 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Example output:

Counter number: 098743
Counter direction: East
Name of county: Baker

then

Each class is listed as a number (0001, 0002, etc) within the given PRN file

So FourAxleDouble = 15 (the number 0007 appeared 15 time)

Motor = 35 (the number 0001 appered 35 times)

So all of these things should be listed in a new text file.
This is what I have so far

Header file////

#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

class Vehicle
{
public:
string Number;
//number of vehicles
int count = 0;
//constructor sets typeNumber
Vehicle(const string &number);
virtual void IncrementCount();
virtual string getNumber();
virtual int getCount();
//returns vechicle type based on vehicle number
virtual string getVehicleType();

};

class TrafficReport : public Vehicle
{

string CounterNo, //(6 digit #)
Direction, //North, east, south, west
CountyName, //Wanye
startTime, //1145
startDate, //121017
endTime, //051316
endDate, //051316
intervalMins; //0015

vector<string> vehicleList;

TrafficReport(string &counter, string &direction, string &county);


};

Implementation File/////

#include "TrafficReport.h"

using namespace std;

Vehicle::Vehicle(const string &number)
{
Number = number;
count = 1;
}

void Vehicle::IncrementCount()
{
count++;
}

string Vehicle::getNumber()
{
return Number;
}

/*int Vehicle::getCount()
{

}*/
void AddVehicle(string vNum)
{
bool f = false;

for (Vehicle v = vehicleList)
{
if (v.getNumber() = vNum)
{
//if already same type vehicle exists
f = true;
v.IncrementCount(); // increment count
break;
}
}

if (f == false && !vNum.equals("0000"))
{
vehicleList.add(new Vehicle(vNum));
size++;
} // add vehicle to list
}

TrafficReport::TrafficReport()
{
CounterNo = counter;
Direction = direction;
CountyName = county;
vehicleList = new vector<string>;
}

//to get a vehicle from list
public Vehicle getVehicle(int i)
{
return vehicleList.get(i);
}
//returns counter number
public string getCounterNo()
{
return CounterNo;
}
public int getListSize()
{
return size;
}
//returns direction
public string getDirection()
{
return Direction;
}
//returns county name
string TrafficReport::getCountyName()
{
return CountyName;
}

Source File/////
#include "TrafficReport.h"

using namespace std;

int main()
{

system("PAUSE");
return 0;
}
Using inheritance is important although it might produce high complexity within the code. Don't worry about it as there are programs that might help with it, as checkmarx. High complexity might lead to bugs and errors and if you want to be able to detect those by yourself, it's important to keep practicing on it.
Topic archived. No new replies allowed.