Project 4 High-Level Design

Inventory Control System for ACME, Inc.
Spring 2000

Product class

class Product {

  friend ostream &operator<<(ostream &, Product);
  friend istream &operator>>(istream &, Product &);

  public:
    Product();
    Product(string, string, int, float);
    string getCode();
    string getDescription();
    int getQty();
    float getPrice();
    void setCode(string);
    void setDescription(string);
    void setQty(int);
    void setPrice(float);
    void set(string, string, int, float);
    void print();

  private:
    string code;
    string description;
    int qty;
    float price;
}; // Product class
Product() --- Default constructor.
Product(string, string, int, float) --- Constructor method that initializes the object to the respective arguments.
string getCode() --- Observer method for the code data member.
string getDescription() --- Observer method for the description data member.
int getQty() --- Observer method for the qty data member.
float getPrice() --- Observer method for the price data member.
void setCode(string) --- Accessor method for the code data member.
void setDescription(string) --- Accessor method for the description data member.
void setQty(int) --- Accessor method for the qty data member.
void setPrice(float) --- Accessor method for the price data member.
void set(string, string, int, float) --- Accessor method for each of the respective data members.
void print() --- Prints the data members of the product in a ``pretty'' format.
friend ostream &operator<<(ostream &, Product) --- Friend function overloading the stream insertion operator.
friend istream &operator>>(istream &, Product &) --- Friend function overloading the stream extraction operator.
Hint: Use the overloaded stream insertion and extraction operators primarily for reading from and writing to the data file.

ProductList class

class ProductList {

  public:
    void load(string);
    void save(string);
    void print();
    void add(Product);
    Product get(int);
    void set(int, Product);
    int find(string);

  private:
    vector<Product> products;
}; // ProductList class
void load(string) --- Loads the products from the file, named by the string argument, into the data member products.
void save(string) --- Saves the products in the data member products to the file named by the string argument.
void print() --- Prints the products in the data member products to cout.
void add(Product) --- Adds the Product object to the data member products.
Product get(int) --- Observer method that retrieves the Product object at the position of the int argument in the vector of Products.
void set(int, Product) --- Accessor method that sets the Product object in the vector at position of the int argument to the argument Product.
int find(string) --- Observer method that finds the Product object in the vector with a code equal to that of the string parameter. If found, the method returns the position of the object in the vector; otherwise, it returns -1 indicating that the product was not found.
vector<Product> products --- Private data member: a vector of Product objects.


ACMEApp class

class ACMEApp {

  public:
    ACMEApp(string);
    ~ACMEApp();
    void HandleEvents();

  private:
    ProductList inventory;
    string filename;
    bool modified;

    void printMenu();
    void addProduct();
    void sellProduct();
    void updateProduct();
    void findProduct();
}; // ACMEApp class
ACMEApp(string) --- Constructor: Given the filename in string, loads the products from the file into the private data member inventory. Stores name in private data member filename. Sets private data member modified to false.
~ACMEApp() --- Destructor: If the inventory has been modified since the last save, the destructor writes the products in the private data member inventory to the file filename.
void HandleEvents() --- Loops by printing the menu, getting a command from the user, and executing the command, until the user quits.
ProductList inventory --- Private data member holding the products in the inventory.
string filename --- Stores the name of the inventory file.
bool modified --- Indicates whether the products in the inventory have been modified.
void printMenu() --- Private method that prints the command menu.
void addProduct() --- Private method for letting the user add a new product to the inventory.
void sellProduct() --- Private method for letting the user indicate that a certain number of a product was sold.
void updateProduct() --- Private method for letting the user increase the quantity of a product.
void findProduct() --- Private method for letting the user find a specific product by searching on the product code.