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
#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();
}*/
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;
}
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.