Question: can you help me troubleshoot my c + + code? #include NodeList.h #include inventory.h / / Ensure correct path if in different directory

can you help me troubleshoot my c++ code?
#include "NodeList.h"
#include "inventory.h"// Ensure correct path if in different directory
Inventory::Inventory(){}
Inventory::Inventory(int capacity){
// Initialize capacity if needed
}
Inventory::~Inventory(){}
Inventory::Inventory(const Inventory& obj) : v_List(obj.v_List){}
Inventory& Inventory::operator=(const Inventory& rhs){
if (this != &rhs){
v_List = rhs.v_List;
}
return *this;
}
bool Inventory::push_Back(Vehicle vehicle){
v_List.insertBack(vehicle);
return true; // Assuming always successful for simplicity
}
void Inventory::sortList(){
// Bubble sort implementation for NodeList
for (auto it1= v_List.begin(); it1!= v_List.end(); ++it1){
for (auto it2= it1; it2!= v_List.end(); ++it2){
if (*it2>*it1){// Assuming Vehicle comparison operators are defined
Vehicle temp =*it1;
*it1=*it2;
*it2= temp;
}
}
}
}
void Inventory::printList(){
for (auto it = v_List.begin(); it != v_List.end(); ++it){
std::cout *it "------------------------------------------
";
}
}
void Inventory::printReservedList(){
for (auto it = v_List.begin(); it != v_List.end(); ++it){
if (!it->status()){
std::cout *it;
}
}
}
void Inventory::printAvailableList(){
for (auto it = v_List.begin(); it != v_List.end(); ++it){
if (it->status()){
std::cout *it;
}
}
}
bool Inventory::found(int seatsNo){
bool found = false;
for (auto it = v_List.begin(); it != v_List.end(); ++it){
if (it->status() && it->getSeats()>= seatsNo){
std::cout *it;
found = true;
}
}
return found;
}
bool Inventory::reserveVehicle(int vehicleID){
int index = checkID(vehicleID);
if (index !=-1 && v_List[index].status()){// Vehicle found and available
v_List[index].reserve();
return true;
}
return false;
}
bool Inventory::returnVehicle(int vehicleID){
int index = checkID(vehicleID);
if (index !=-1 && !v_List[index].status()){// Vehicle found and reserved
v_List[index].unReserve();
return true;
}
return false;
}
int Inventory::checkID(int vehicleID){
int index =0;
for (auto it = v_List.begin(); it != v_List.end(); ++it,++index){
if (it->getID()== vehicleID){
return index;
}
}
return -1; // Vehicle not found
}
bool Inventory::saveToFile(const std::string& fileName){
std::ofstream outFile(fileName);
if (!outFile){
std::cerr "Error opening file " fileName std::endl;
return false;
}
for (auto it = v_List.begin(); it != v_List.end(); ++it){
outFile *it;
}
outFile.close();
return true;
}
std::ofstream& operator(std::ofstream& out, const Inventory& objV){
for (auto it = objV.v_List.begin(); it != objV.v_List.end(); ++it){
out *it;
}
return o#pragma once
#ifndef INVENTORY_H
#define INVENTORY_H
#include
#include
#include
#include "NodeList.h"
#include "vehicle.h"
class Inventory {
private:
NodeList v_List; // NodeList of vehicles
public:
Inventory();
Inventory(int capacity);
~Inventory();
Inventory(const Inventory& obj);
Inventory& operator=(const Inventory& rhs);
void sortList();
void printList();
void printReservedList();
void printAvailableList();
bool found(int seatsNo);
bool reserveVehicle(int vehicleID);
bool returnVehicle(int vehicleID);
int size() const { return v_List.size(); }
// Method to add vehicle to NodeList
bool push_Back(Vehicle ve);
// Method to check vehicle ID in NodeList
int checkID(int _vehicleID_);
// Method to save inventory to file
bool saveToFile(const string& fileName);
friend std::ofstream& operator(std::ofstream& outfile, const Inventory& objV);
};
#endif // INVENTORY_H
 can you help me troubleshoot my c++ code? #include "NodeList.h" #include

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!