I need the source code for the following program to be completed in C++. Please
ID: 3672972 • Letter: I
Question
I need the source code for the following program to be completed in C++. Please include good code commenting so that even a beginner or nontechnical user could understand what is taking place. I will include two files that are necessary for the program to work with and the requirements for the program will be copy/pasted below. It is very important that you indicate headings for your .cpp and .h files so I know where to put them in the program compiler when it's all separated out. Thank you.
The first file to work with is InventoryItem.cpp and is below:
The second file to work with is InventoryItem.h and is below:
Cash Register. This program will use two classes: one of the classes is provided in the assignment description for week 7 in the course site. Write a class name CashRegister, with the class declaration in a file called CashRegister.h and the implementation in a file called CashRegister.cpp. This class will interact with the Inventoryltem class that has been provided. The program should display a list of items that are available to purchase.Explanation / Answer
#ifndef INVENTORYITEM_H
#define INVENTORYITEM_H
#include<cstring>
using namespace std;
const int DEFAULT_SIZE = 51;
class InventoryItem
{
private:
char *description;
double cost;
int units;
void createDescription(int size, char *value)
{
description = new char [size*'()'];
strcpy(description,value);}
public:
InventoryItem()
{
createDescription(DEFAULT_SIZE, "");
cost = 0.0;
units = 0;
}
InventoryItem(char *desc)
{
createDescription(strlen(desc),desc);
cost = 0.0;
units = 0;
}
InventoryItem(char *desc,double c,int u)
{
createDescription(strlen(desc),desc);
cost = c;
units = u;
}
~InventoryItem()
{
delete [] description;
}
void setDescription(char *d)
{
strcpy(description,d);
}
void setCost(double c)
{
cost = c;
}
void setUnits(int u)
{
units = u;
}
const char *getDescription()const
{
return description;
}
double getCost() const
{
return cost;
}
int getUnits () const
{
return units;
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.