Design an inventory class that can hold information and calculate data for print
ID: 3818829 • Letter: D
Question
Design an inventory class that can hold information and calculate data for prints created and sold by the photography dude
Please create the pseudocode, and then code, debug, and create the submittal files for following problem: Design an inventory class that can hold information and calculate data for prints created and sold by the photography dude (see Lesson 11 Assignment All the member variables will be private and all the member functions will be public Variable Name: Description (a are private) image Number an int that holds the item's image number a string that holds the image name up to 25 characters) image Name filmType a string that holds the film type used (string up to 5 characters a float that holds the sales price of each print price Prints prints Sold an int that holds the number of prints sold to date Member Functions Description all are public Default Constructor sets all the member variables to 0 or to Constructor #2 accepts a print's imageNumber, imageName, filmType, pricePrints, prints Sold. The function should copy these values to the appropriate variables. setlmageNumber accepts an integer argument that is copied to the imageNumber variable validate for 0 accepts a string argument that is copied to the imageName variable validate for not empty setlmageName accepts a string argument that is copied to the filmType variable validate for not empty etFilmType accepts a float argument that is copied to the pricePrints variable validate for 0 setPrice Prints setPrints Sold accepts an int argument that is copied to the printsSold variable validate for 0 calculates the total income made from sales (pricePrints printsSold getTota ncome getlmageNumber returns the value in imageNumber variable getlmageName return the value in imageName variable get FilmType returns the value in filmType variable getPricePrints returns the value in pricePrints variable returns the value in printsSold variable get PrintsSold The mutator functions should have an additional layer of validation protection as described in the list above. Creating this bottom-level layer of protection does not negate the need to validate the user input in whatever function calls the mutator function. Make sure to review page 744, "contents of Rectangle. cpp(Version 2) for an example of exit failure. Remember, your data is protected by it's member functions. You can't trust anybody! Use your integer input function and your float input function as you did beforeExplanation / Answer
#include<iostream>
#include<string>
using namespace std;
class inventory
{
int imageNumber;
string imageName;
string filmType;
float pricePrints;
int printSold;
public:
inventory()
{
imageNumber = 0;
imageName = "";
filmType = "";
pricePrints = 0;
printSold = 0;
}
inventory(int imgNo, string imgName, string flmType, float pricePrnt, int prntSold)
{
imageNumber = imgNo;
imageName = imgName;
filmType = flmType;
pricePrints = pricePrnt;
printSold = prntSold;
}
void setImageNumber(int no)
{
imageNumber = no;
}
void setImageName(string name)
{
imageName = name;
}
void setFilmType(string type)
{
filmType = type;
}
void setPricePrints(float price)
{
pricePrints = price;
}
void setPrintSold(int sold)
{
printSold = sold;
}
int getImageNumber()
{
return imageNumber;
}
string getImageName()
{
return imageName ;
}
string getFilmType()
{
return filmType ;
}
float getPricePrints()
{
return pricePrints;
}
int getPrintSold()
{
return printSold ;
}
float getTotalIncome()
{
return (pricePrints * printSold);
}
void display()
{
cout << "Image Number = " << imageNumber << " Image Name = " << imageName << " Film Type = " << filmType << " price per print = " << pricePrints << " Print sold = " << printSold << " Total income = " << getTotalIncome() << endl;
}
};
int main()
{
inventory **inventory_array;
//create array of 3 objects
inventory_array = new inventory*[3];
int no, sold;
string name, type;
float price;
//take user input and create fill array of objects with user input
for (int i = 0; i < 3; i++)
{
cout << "Image Number = ";
cin >> no;
cout << " Image Name = ";
cin.ignore();
std::getline(std::cin, name);
cout << " Film type = ";
std::getline(std::cin, type);
cout << " price per prints = ";
cin >> price;
cout << " prints sold= ";
cin >> sold;
inventory_array[i] = new inventory(no, name, type, price, sold);
}
//display output for each objects
for (int i = 0; i < 3; i++)
{
//inventory_array[i]->display();
cout << "Image Number = " << inventory_array[i]->getImageNumber() << " Image Name = " << inventory_array[i]->getImageName() << " Film Type = " << inventory_array[i]->getFilmType() << " price per print = " << inventory_array[i]->getPricePrints() << " Print sold = " << inventory_array[i]->getPrintSold() << " Total income = " << inventory_array[i]->getTotalIncome() << endl;
}
}
--------------------------------------------------------------------------------------------------------------------------------------
//output
prints sold= 5
Image Number = 20
Image Name = Jog falls
Film type = scenic
price per prints = 100
prints sold= 10
Image Number = 30
Image Name = Grand canyon
Film type = adventure
price per prints = 80
prints sold= 8
Image Number = 10 Image Name = Great wall of china Film Type = historic price p
er print = 50 Print sold = 5 Total income = 250
Image Number = 20 Image Name = Jog falls Film Type = scenic price per print = 1
00 Print sold = 10 Total income = 1000
Image Number = 30 Image Name = Grand canyon Film Type = adventure price per pri
nt = 80 Print sold = 8 Total income = 640
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.