Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 seats availabletrue extraFeatures
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
cout "Basic trim" endl;
else
cout ;
for sizet i ; i featuresList.size; i
cout featuresListi;
if i featuresList.size cout ;
cout endl;
;
ostream& operatorostream& 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 objVavailable
out "Availability: available" endl;
else
out "Availability: Not available" endl;
out "Extra Features objV.extraFeatures : ;
if objVextraFeatures
out "Basic trim" endl;
else
out ;
for sizet i ; i objV.featuresList.size; i
out objV.featuresListi;
if i objV.featuresList.size out ;
out endl;
out endl;
return out;
ofstream& operatorofstream& 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;
DNodeconst T& e T DNode p nullptr, DNode n nullptr : eleme prevp nextn
;
DoublyLinkedList class definition
template
class DoublyLinkedList
public:
DoublyLinkedList;
~DoublyLinkedList;
bool empty const;
void addFrontconst T& e;
void addBackconst T& e;
void removeFront;
void removeBack;
void printAll const;
DNode getHead const return headernext;
DNode getTail const return trailer;
private:
DNode header;
DNode trailer;
;
template
DoublyLinkedList::DoublyLinkedList
header new DNode;
trailer new DNode;
headernext trailer;
trailerprev header;
template
DoublyLinkedList::~DoublyLinkedList
while empty removeFront;
delete header;
delete trailer;
template
bool DoublyLinkedList::empty const
return headernext trailer;
template
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started