Hi!
I am doing a project that's about inheritance and I've solved the most of it. I have some problems with removing a vehicle (car or motorcycle) because they have different characteristics.
A car has these characteristics: brand, age, regNr, price, fuel, size
A motorcycle has these characteristics: brand, age, regNr, price, storageCape
If they'd had the same characteristics there wouldnt be any problems.
Here is when I add a car:
void VehicleManager::addCar(string brand, string age, string regNr, string price, string fuel, string size)
{
if (this->m_count == this->m_capacity)
{
Vehicle **temp = new Vehicle*[this->m_capacity + 5];
for (int i=0; i<m_capacity; i++)
{
temp[i] = this->m_ppVehicles[i];
}
delete [] this->m_ppVehicles;
m_capacity += 5;
this->m_ppVehicles = temp;
}
this->m_ppVehicles[this->m_count] = new Car();
(this->m_ppVehicles[this->m_count])->setVehicle(brand, age, regNr, price, "", fuel, size);
this->m_count++;
}
and here is when i add a motorcycle
void VehicleManager::addMotorcycle(string brand, string age, string regNr, string price, string storageCape)
{
if (this->m_count == this->m_capacity)
{
Vehicle **temp = new Vehicle*[this->m_capacity + 5];
for (int i=0; i<m_capacity; i++)
{
temp[i] = this->m_ppVehicles[i];
}
delete [] this->m_ppVehicles;
m_capacity += 5;
this->m_ppVehicles = temp;
}
this->m_ppVehicles[this->m_count] = new Motorcycle();
(this->m_ppVehicles[this->m_count])->setVehicle(brand, age, regNr, price, storageCape);
this->m_count++;
}
I want that the program asks the user what registration number the vehicle has, and based on the registration number the program removes either a motorcycle or a car.
Grateful for answers!