Hi,
I have a problem, I dont know how to import data into a single array and then output it to the screen. I am quite new to c++ and would approciate your help.
Here is information:
When a vehicle has been manufactured, it has the following attributes: make (e.g. \Ford"), model(e.g. \Focus"), a number of wheels and a weight in kilograms. In order to sell it, the vehicle must be registered by the DVLA, which allocates it a number plate consisting of seven alphanumeric characters and records the date on which it was registered and the name of the registered keeper.If the vehicle is to be used as a taxi, then, as well as vehicle registration, further taxi registration is required. It must be registered by the local authority, which allocates it a ten-digit taxi licence number.
vehicles.txt le. It contains details about a number of vehicles, some of which may be registered by the DVLA and some of which may also be registered as taxis.The denitions of the elds in each record of the le are described in the table below.
- I need to write Vehicle class, RegisteredVehicle class and RegisteredTaxi class whch extends RegisteredVehicle class.
-Read in the information from the vehicles.txt le and store the data in a single array of
objects
-Print out a report to the screen from the array of objects that has been created. It should look like this:
Make Model Wheels Weight Plate Date Registered Keeper Licence
----------- ----------- ------- ------- ------- -------- ---------------- ----------
Ford Focus 4 1200 XX12ABC 20100901 J Bloggs
Volkswagen Beetle 4 1310
Vauxhall Astra 4 1121 XY34WXZ 20030125 Aardvark's Taxis 0012567890
Reliant Robin 3 989 AB78DGH 20010329 D Trotter
Scania R420 Tipper 8 32500
Total: 5 vehicles
Broadly, I have started with classes. I am new to c++ and do not know how to read data from text file and output it to the screen by the format shown above. I would be very greatful if u help me to sort it out and show me the right pathway. P/S: The content of vehicle.txt is the same as the table above but without headings of columns.
What I have started:
#include <iostream>
using namespace std;
#ifndef VEHICLE_H
#define VEHICLE_H
//Create the class Vehicle
class Vehicle {
protected:
char make[11];
char model[21];
int numWheels[3];
float weight[8];
public:
void initialize(int in_numWheels, float in_weight);
int get_numWheels(void);
float get_weight(void);
}
//Create the class RegisteredVehicle that extends Vehicle class
class RegisteredVehicle : public Vehicle()
{
char numberPlate[8];
int registrationDate[9];
char registeredKeeper[21];
int taxiLicence[11];
public:
void initialize(int registrationDate, int taxiLicence);
int get_registrationDate(void);
int get_taxiLicence(void);
}
//Create the class RegisteredTaxi that extends RegisteredVehicle class
class RegisteredTaxi : public RegisteredVegicle()
{
protected:
int taxiLicence[10];
public:
void initialize(int taxiLicence);
int get_taxiLicence(void);
}