Question: Please help troubleshoot some problems with my program. It is not printing the lists that it should. Problem Description: In this project, you are expected

Please help troubleshoot some problems with my program. It is not printing the lists that it should.
Problem Description:
In this project, you are expected to design and fully implement a car rental system (a subsystem of a full system) that controls the vehicle's partial activities within the inventory. The system is expected to help the inventory automate its vehicle reservation and query processes (without getting involved in the customer information). It uses a data structure to keep track of the vehicle inventory in the system (please use Doubly Linked List). Moreover, vehicle information is already provided in a text file ( vehicles.txt Download vehicles.txt), and no need to worry about inserting new vehicles into the file. However, the system needs to update the file after each reservation or return process.
Your system should be able to perform at least the following operations:
Print All of the registered vehicles. (available and already reserved)
Print list of the available vehicles.
List of the reserved vehicles (rented currently by customers).
Check availability.
Reserve a vehicle.
return a reserved vehicle.
Print All of the registered vehicles to a text file.
Exit
Note: If you add the insertion option, you will get extra points.
Here is the code:
#include
#include
#include
#include
using namespace std;
// Vehicle class definition
class Vehicle {
public:
int vehicleID;
string make;
string model;
int seats;
bool available;
int extraFeatures;
vector featuresList;
Vehicle() : vehicleID(0), seats(0), available(true), extraFeatures(0){}
void printVehicle() const {
cout <<"ID: "<< vehicleID << endl;
cout << "Make: "<< make << endl;
cout << "Model: "<< model << endl;
cout << "Number of seats: "<< seats << endl;
cout << "Availability: "<<(available ? "available" : "Not available")<< endl;
cout << "Extra Features["<< extraFeatures <<"]: ";
if (extraFeatures ==0){
cout << "Basic trim" << endl;
}
else {
cout <<"[";
for (size_t i =0; i < featuresList.size(); ++i){
cout << featuresList[i];
if (i < featuresList.size()-1) cout <<",";
}
cout <<"]"<< endl;
}
}
};
ostream& operator<<(ostream& out, const Vehicle& objV){
out <<"---------------------------------------------------------"<< endl;
out <<"ID: "<< objV.vehicleID << endl;
out << "Make: "<< objV.make << endl;
out << "Model: "<< objV.model << endl;
out << "Number of seats: "<< objV.seats << endl;
if (objV.available)
out << "Availability: available" << endl;
else
out << "Availability: Not available" << endl;
out << "Extra Features["<< objV.extraFeatures <<"]: ";
if (objV.extraFeatures ==0){
out << "Basic trim" << endl;
}
else {
out <<"[";
for (size_t i =0; i < objV.featuresList.size(); ++i){
out << objV.featuresList[i];
if (i < objV.featuresList.size()-1) out <<",";
}
out <<"]"<< endl;
}
out <<"---------------------------------------------------------"<< endl;
return out;
}
ofstream& operator<<(ofstream& outFile, const Vehicle& car){
outFile << car.vehicleID << endl;
outFile << car.make << endl;
outFile << car.model << endl;
outFile << car.seats << endl;
outFile << car.available << endl;
outFile << car.extraFeatures << endl;
for (const auto& feature : car.featuresList){
outFile << feature << endl;
}
return outFile;
}
// Node class for doubly linked list
template
class DNode {
public:
T elem;
DNode* prev;
DNode* next;
DNode(const T& e = T(), DNode* p = nullptr, DNode* n = nullptr) : elem(e), prev(p), next(n){}
};
// DoublyLinkedList class definition
template
class DoublyLinkedList {
public:
DoublyLinkedList();
~DoublyLinkedList();
bool empty() const;
void addFront(const T& e);
void addBack(const T& e);
void removeFront();
void removeBack();
void printAll() const;
DNode* getHead() const { return header->next; }
DNode* getTail() const { return trailer; }
private:
DNode* header;
DNode* trailer;
};
template
DoublyLinkedList::DoublyLinkedList(){
header = new DNode();
trailer = new DNode();
header->next = trailer;
trailer->prev = header;
}
template
DoublyLinkedList::~DoublyLinkedList(){
while (!empty()) removeFront();
delete header;
delete trailer;
}
template
bool DoublyLinkedList::empty() const {
return header->next == trailer;
}
template

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!