Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Serious c++ help ! This the question Create an Inventory class with the followin

ID: 662871 • Letter: S

Question

Serious c++ help !

This the question

Create an Inventory class with the following properties:

InvNumber: A string used to hold an inventory number. Each item in the inventory should have a unique inventory number.

Description: A string that holds a brief description of the item.

Cost: A decimal value that holds the amount that the retail store paid for the item.

Retail: A decimal value that holds the retail price of the item.

OnHand: An integer value that holds the number of items on hand. This value cannot be less than 0.

Create constructors, destructors, accessors, mutators, and custom methods as needed

What I got for this

#pragma once

#include <iostream>

using namespace std;

class Inventory{

private:

   string InvNumber;

   string Description;

   double Cost;

   double Retail;

   int OnHand;

public:

   Inventory(string in, string d, double c, double r, int o){

       InvNumber = in;

       Description = d;

       Cost = c;

       Retail = r;

      >

   }

   ~Inventory(){

     

   }

   void setInvNumber(string in){

       InvNumber = in;

   }

   void setDescription(string d){

       Description = d;

   }

   void setCost(double c){

       Cost = c;

   }

   void setRetail(double r){

       Retail = r;

   }

   void setOnHand(int o){

      >

   }

   string getInvNumber(){

       return InvNumber;

   }

   string getDescription(){

       return Description;

   }

   double getCost(){

       return Cost;

   }

   double getRetail(){

       return Retail;

   }

   int getOnHand(){

       return OnHand;

   }

};

however my feedback was

it is not necessary at this point but you should separate the Inventory class into a header file and a cpp file

the constructor should verify the parameters

the mutators should verify the paramters

the constructors and the mutators make sure that the class data is "good"

Explanation / Answer

#include <bits/stdc+.h>
using namespace std;

class Inventory{
private:
string InvNumber;
string Description;
double Cost;
double Retail;
int OnHand;
public:
Inventory(string in, string d, double c, double r, int o){
InvNumber = in;
Description = d;
Cost = c;
Retail = r;
> }
~Inventory(){

}
void setInvNumber(string in){
InvNumber = in;
}
void setDescription(string d){
Description = d;
}
void setCost(double c){
Cost = c;
}
void setRetail(double r){
Retail = r;
}
void setOnHand(int o){
> }

string getInvNumber(){
return InvNumber;
}
string getDescription(){
return Description;
}
double getCost(){
return Cost;
}
double getRetail(){
return Retail;
}
int getOnHand(){
return OnHand;
}

};

int main(){
   map<char,int> mymap;
   string I;
    string D;
    double C;
    double R;
    int O;
   while (true)
       cout << "Enter inventory number ";
       cin >> I;
       if (map.find(I) == map.end())
           continue;
       map[I] = 1;
       break;
   }
   cout << "enter brief description of the item. ";
   cin >> D;
   cout << "enter amount that the retail store paid for the item. ";
   cin >> C;
   cout << "enter holds the retail price of the item. ";
   cin >> R;
   while (true)
       cout << "enter holds the number of items on hand";
       cin >> O;
       if (O < 0)
           continue;
       break;
   }
   Inventory *in = new Inventory(I,D,C,R,O);
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote