cpp_lab2_f07 - LAB EXAM 2 A SMALL INVENTORY SYSTEM CGS 2425...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
LAB EXAM 2: A SMALL INVENTORY SYSTEM CGS 2425 2007 Fall In this test you are asked to implement a small inventory system that keeps track of parts inventory for a store. You will implement two object classes: store and part . There are three data fields associated with each part in the inventory: partNo : identifies the part -- string (ex: XP04A ) partCost : cost of the part -- double (ex: 40.46) partQ : quantity -- int (ex: 60) The complete definition of part class is given below. class part { private: string partNo; double partCost; int partQ; public: part(void){partCost = 0.0; partQ=0; } // constructor part(string,double,int); // constructor void setquantity(int n){ partQ = n;} int getquantity(void){return partQ;} void print(); bool exist(string); //check if the partNo exists. }; part::part(string s, double c, int q) { partNo = s; partCost = c; partQ = q; } bool part::exist(string pn) { if( partNo == pn ) return true; else return false; } void part::print(void) { cout << partNo << " " << partCost << " " << partQ << endl; } There are four data fields associated with the store. -- partSet[] is an array of part objects, which store the inventory information. You may assume there are at most 100 different type parts in the store. -- number indicates the number of part type in the store. -- totalCost indicate the total cost for the inventory, which is the sum of products of cost and quantity of different type. -- revenue indicates the revenue of the store, which is the sum of the products of sale price and sale quantity of each part. The definition of store class with some methods is given below.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
class store { private: part partSet[100]; int number; double totalCost; double revenue; public: store(void){number = 0; totalCost = revenue = 0.0;} void readFrom(string filename); void addPart(string,double,int); void sale(string,double,int); void print(void); // given below }; void store::print(void){ for (int i = 0; i < number; i++) { partSet[0].print(); } cout << "Total Cost: " << totalCost << endl; cout << "Revenue:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

cpp_lab2_f07 - LAB EXAM 2 A SMALL INVENTORY SYSTEM CGS 2425...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online