A10: Storing Objects

On This Page


Overview

During this assignment, you will:

  • Write a class that models a store
  • Reuse a class from a prior assignment
  • Use an array of objects

Specifications

Write a Store class that loads up to five Products from a file. Use your Product class from the last assignment to store the information for each product in your store. Use the Store.cpp starter code to begin development.

Sample Operation

  1. The program displays a list of products plus an option to exit.
  2. Welcome to our virtual store!
    
    Our Products:
    #. Name                 Price   Qty     Value
    1. Baseball caps        7.99    50      399.5
    2. Traditional mugs     5.99    15      89.85
    3. Large T-shirts       12.99   60      779.4
    
    Please choose a product to purchase
    or enter 0 to exit: 4
    
  3. As long as the user does not select a valid product, the program displays and error message and allow the user to make another choice.
  4. Not a valid choice!
    
    Please choose a product to purchase
    or enter 0 to exit: 1
    
  5. Whenever the user selects a valid product, the program reduces the inventory by one like the following:
  6. Our Products:
    #. Name                 Price   Qty     Value
    1. Baseball caps        7.99    49      391.51
    2. Traditional mugs     5.99    15      89.85
    3. Large T-shirts       12.99   60      779.4
    
    Please choose a product to purchase
    or enter 0 to exit: 0
    
    Goodbye!
    

Required Functions

You must code the following functions exactly as specified, though you may add more functions if you like.

/**
 * Constructs a Store.
 */
Store();

/**
 * Initializes the Store data.
 *
 * @param size The maximum number of Products in this Store..
 */
void loadProducts(int size);

/**
 * Reports the store inventory.
 */
void reportInventory();

/**
 * Records the sale of a Product by decrementing the inventory.
 *
 * @param item The item in the array of the Products that was sold.
 */
void sellProduct(int item);

/**
 * Gets a valid product selection from the user.
 *
 * @return The index n the array of the product selected.
 */
int chooseProduct();

Additional Specifications

  1. The name of the store application source code file must be Store.cpp.
  2. The name of the file that initializes the store must be products.txt.
  3. You program must read a products.txt file in the following format
  4. Your program must catch and handle all error conditions.
  5. When the user enters a 0 the program must end.
  6. Do not forget to document all the code. Though I have put a few comments in the starter code, you are responsible for the accuracy and completeness of the final comments.

Extra Credit

Adding the following are worth extra credit points:

  1. Complete the assignment using pair programming. (1 point)
  2. Write a Makefile for the application and use separate compilation. (2 points)

Make certain that your README.txt file describes any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Program Compilation

  • 4: Source code compiles with no errors or warnings
  • 2: Source code compiles with warnings
  • 0: Does not compile or wrong file turned in

Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lesson(s) appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute or no specifications met

Code Documentation

  • 4: Code is well-documented
  • 3: Code has minor documentation errors
    • Has 1 documentation error
  • 2: Code has some documentation errors
    • Has 2-3 documentation errors
  • 1: Code has many documentation errors
    • Has more than 3 documentation errors
  • 0: No apparent attempt to document code

REAME.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Maximum Score: 20, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Include the following items for grading:

  1. README.txt file
  2. Product.cpp
  3. Store.cpp
  4. Any other source code needed to make your program function.

You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.

Home | WebCT | Announcements | Day Schedule | Eve Schedule
Course info | Help | FAQ's | HowTo's | Links

Last Updated: November 17 2004 @17:02:28