#include #include #include #include #include using namespace std; #include "Grocery.h" //Grocery methods Grocery::Grocery() { name = "undefined"; markup = 1.0; cost = 0; } Grocery::Grocery( ifstream& fin ) { Extract( fin ); } Grocery::Grocery( string Name, double Markup, int Cost ) { name = Name; markup = Markup; cost = Cost; } string Grocery::getName() const { return name; } double Grocery::getMarkup() const { //markup is always >= 0.0 //markup == 1.0 for no profit return markup; } int Grocery::getCost() const { //cost is non-negative measured in cents return cost; } int Grocery::getPrice() const { return (int)(cost * markup + 0.5); } void Grocery::Extract(ifstream& fin ) { string opentkn, closetkn; fin >> opentkn; //error check: opentkn == "Grocery{" Get( fin ); fin >> closetkn; //error check: closetkn == "}Grocery" } void Grocery::Insert( ostream& fout ) { fout << endl; fout << " Grocery{ "; Put( fout ); fout << " }Grocery "; } void Grocery::Get( ifstream& fin) { string label1, label2, label3; fin >> label1 >> name >> label2 >> markup >> label3 >> cost; //error checks: label1 == "name:" && // label2 == "markup:" && // label3 == "cost:" } void Grocery::Put ( ostream& fout) { fout << " name: " << name << " markup: " << markup << " cost: " << cost; }