Course Solutions Uncategorized (Solved) : Code Previous Exercise Let Know Need Question Code Include Include Include Include Include Q30110728 . . . .

(Solved) : Code Previous Exercise Let Know Need Question Code Include Include Include Include Include Q30110728 . . . .

 

//This was code from a previousexercise – let me know if you need the question for this code.

#include<iostream>

#include<fstream>

#include<vector>

#include<string>

#include<cstdlib>

#include<cstring>

using namespace std;

class InventoryItem{

private:

string description;

int quantityOnHand;

double price;

public:

InventoryItem()

{

description=”NULL”;

quantityOnHand=0;

price=0;

}

InventoryItem(string desc, int q, double p)

{

description=desc;

quantityOnHand=q;

price=p;

}

string getDescription()

{

return description;

}

int getQuantityOnHand()

{

return quantityOnHand;

}

double getPrice()

{

return price;

}

void setDescription(string d)

{

this->description=d;

}

void setPrice(double p)

{

this->price=p;

}

void setQuantityOnHand(int q)

{

this->quantityOnHand=q;

}

void display()

{

cout<<“Description:”<<description<<endl<<“Quantity:”<<quantityOnHand<<endl<<“Price:”<<price<<endl;

}

void read(ifstream &inFile)

{

string line;

getline(inFile, line, ‘,’);

setDescription(line);

int q; double p; char comma;

inFile >> q;

setQuantityOnHand(q);

inFile >> comma;

inFile >> p;

setPrice(p);

inFile.ignore(100, ‘n’);

}

};

int main()

{

ifstream input;

input.open(“inventory.txt”);

vector<InventoryItem> inventory;

while(!input.eof())

{

InventoryItem item;

item.read(input);

inventory.push_back(item);

}

//print the data

for(int i=0; i<inventory.size(); i++)

{

inventory.at(i).display();

cout<<endl<<endl;

}

cin.get();

return 0;

}

//This was the task before theexercise 1 that I need.

Exerise 1.Declare a classBook as a derived class of InventoryItem. You only need to do theclass specification in this

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post