I need some assistance with this lab, any help will be appreciated. I will attach a .txt file, with my programming so far.


Thanks, I appreciate all those who take time out of their day to help.



Description


Modify the Inventory program from Lab 5 to add file I/O to the Inventory class. Perform the following.
Inventory Class

Add class level attributes and methods to maintain the list of loans. The array of inventory items should be kept in the Inventory class using a class level array (static).

Add the class level data member to store the number of inventory items.

The sortInventory and searchInventory functions will be part of the Inventory class instead of separate functions. They will be class level functions.

A new class level member function called getNumberOfItems will be added to return the number of inventory items in the file (array).

A new class level member function called initialize that will open the Inventory file, read the inventory records and add inventory objects to the array.

A new class level member function called terminate that will write the records back to the file and close the file.

A new class level member function call addInventory will be added to add an inventory item to the array.

A new class level member function called deleteInventory will be added to delete an inventory item from the array.

A new class level member function called updateInventory will be added to update an inventory item .

A new class level member function called getInventory will be added to return the nth inventory item.

main.cpp – Source File

The options in main will remain the same. It will need to be modified to use the new class level functions.
Inventory.txt – Data File


The file is a Sequential Access file with fixed length records containing the inventory ID, type, description, quantity, and unit cost for each inventory item.

But what is your actual question?

Just read through the description and I need help altering my program to get this thing. You will have to look at my program first and then read the description to understand this better.

The descriptions appear to be pretty clear to me. Just start at the top of the list and implement each one at a time. After you do the first requirement then compile and fix all errors. Then go on to the next requirement.

Sorry I am really new at C++ programming and I need a push start on how to apply these.
Thanks

I actually took the time to do that project and find some confusing instructions:

>> Add class level attributes and methods to maintain the list of loans.
This is an inventory program, not a loan progam.

many of those new Inventory class methods need to be static, not class-level member functions. For example, searchInventory can't be used as a class-level function because you need an instance of the class to call it, which doesn't make sence. Several others are like that too.

I think you need to get clarification of these issues with your instructor.

Thank you so much for trying to do this, I will either see my instructor tomorrow or Monday. I will let you know what he says, but he's not the greatest teacher and I know he is teaching us things that are not as effiecient as others. But I will let you know.

This is all I got out of the instructor, see if you can get anything with this.

Believe this goes in the Inventory.cpp

Inventory::addInventory(Inventory variableName) void addInventory(Inventory);
{
inventoryItems[numberOfItems]=variableName;
numberOfItems ++;
}
Inventory Inventory::getInventory(int n)
{
return inventoryItems[n];
}


Then add this to the Inventory.h

Private:
static Inventory inventoryItems[25];
static int numberofItems;

Public:
static void addInventory(Inventory);
static Inventory getInventory(int);

though, yo have not solved out what AD said... there's a lot of function in your inventory class that you should better use as general functions...

This is some more stuff. I am this close to paying someone to do this for me.

main.cpp
  case 5:
/*
   cout << setw(11) << left << "\nID"
     << setw(18) << left << "Type"
     << setw(16) << left << "Description"
     << setw(9)  << left << "QOH"
     << setw(11) << left << "Cost"
     << left << "Price"
     << endl;
   for (i=0; i< Inventory::getNumberOfItems(); i++)
   
   {
    inventoryItems = Inventory::getInventory(i);
    sortInventory(inventoryItem, id, numberOfItems);
    cout << setw(10) << left << inventoryItem[i].getID()
      << setw(19) << left << inventoryItem[i].getTypeString()
      << setw(16) << left << inventoryItem[i].getDescription()
      << setw(9)  << left << inventoryItem[i].getQuantity()
      << setw(10) << left << setprecision(2) << fixed << inventoryItem[i].getUnitCost()
      << setprecision(2)  << left << fixed << inventoryItem[i].getPrice()
      << endl;
   }
*/   
   break;
 

Inventory.h
#ifndef INVENTORY_H
#define INVENTORY_H
#include <string> //program uses string
using std::string; //program uses string
class Inventory //Inventory class definition
{
 private:
  
  int inventoryID; //variable
  int inventoryType, type; //variable
  string inventoryDescription; //variable
  int inventoryQuantity; //variable
  float inventoryUnitCost; //variable
  string getType; //variable
  static Inventory inventoryItems[25];
  static int numberOfItems;
  
 public:
  
  void addItems(int, float); //function to update the quantity and unit cost of the Inventory
  
  string getDescription(); //function to retrieve the item description
  int    getID(); //function to retrieve the item ID
  float  getPrice(); //function to retrieve the item's price
  int    getQuantity(); //function to retrieve the item's quantity
  float  getUnitCost(); //function to retrieve the item's unit cost
  int    getInventoryType(); //function to retrieve the Inventory type
  float  getPriceDurable(); //function to retrieve the Durable price
  float  getPriceClothing(); //function to retrieve the Clothing price
  float  getPriceGrocery(); //function to retrieve the Grocery Price
  string getTypeString();  //function to retrieve the type string
  void setDescription(string); //function to set the item description
  void setID(int); //function to set the item ID
  void setQuantity(int); //function to set the item quantity
  void setInventoryType(int); //function to set the inventory type
  void setUnitCost(float); //function to set the unit cost
  static void addInventory(Inventory);   (one of these is not needed, can't remember which one)
  static Inventory getInventory(int);
  static getNumberOfItems;
  static Inventory addInventory(inventoryItem);
  static bool termination();
};
#endif

Inventory.cpp
(This stuff at the top)
#include ofstream;
using std::ofstream;
using STD::ifstream;
#include "Inventory.h" //include the Inventory header file
Inventory Inventory::inventoryItems[25],
int Inventory::numberOfItems = 0;
Inventory::addInventory(Inventory variableName) void addInventory(Inventory);
{
 inventoryItems[numberOfItems]=variableName;
 numberOfItems ++;
}
Inventory Inventory::getInventory(int n)
{
 return inventoryItems[n];
}
void Inventory::addInventory(Inventory Item)
{
 inventoryItems(numberOfItems) = item
 numberOfItems++
}

(This stuff at the bottom)

bool Inventory::termination()
{
 ofstream outFile('Inventory.txt'. int::out)
  if (!outFile)
   return false
 for (int i = 0 i < numberOfItems i++)
 {
  outFile.write(reinterpret_cast(char *> (&inventoryItems[i]. inventoryID).sizeof(inventoryID))
  outFile.write(reinterpret_cast(char *> (&inventoryItems[i]. inventoryType).sizeof(inventoryType))
  outFile.write(reinterpret_cast(char *> (&inventoryItems[i]. inventoryQuantity).sizeof(inventoryQuantity))
  outFile.write(reinterpret_cast(char *> (&inventoryItems[i]. inventoryUnitCost).sizeof(inventoryUnitCost))
 }
 return true
}

Thanks for the help

Please keep posting and give me some more ideas with this. I know I am not the greatest help, but I will try to answer what I can. Any assistance would be a great deal of help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.