A9-Keeping Lists

On This Page


Overview

There are three parts to this assignment:

  1. Review Exercises:

    First make sure you have completed and turned in the exercises from lesson 9. Then complete the exercises in CodeLab 9. These exercises will help prepare you for the problem-solving program and should be completed first.

  2. Problem Solving Program:

    Complete the programming project following the Program Specifications listed below. You may make extra credit additions to this program as outlined in the section on Extra Credit.

  3. Tutorial Exercises:

    Type the babynames.cpp program from the textbook on pages 332 through 333 into a text editor, and then compile and run the program. Submit the source code file to Blackboard for grading. Use the babynames.txt file to test your program.

Program Specifications

When developing this program, you will use your Product class from the last assignment to develop a program to manage a store. Use a vector of Product objects to hold the products for the store. Visualize the vector as a series of shelves to hold the products. Each product sits on one of the shelves. The shelves are identified by a number as shown below:

products = 
milk
bread
cheese
jam
[0]
[1]
[2]
[3]

From a software standpoint, the vector holds the Product objects, one object to each slot. You can change the inventory in each slot by selling or restocking products. In addition, you can add or delete products in the store. The specifications are listed below.

Note that you must complete this program either by yourself or by working with one other student of this class following the rules of Pair Programming for Homework Assignments.

  1. Using your Product class from the last assignment, develop an application that manages a store of products.

    Keep the same class name. Do not add any new member variables to the class (including vectors) and do not remove any of the functions specified in the last assignment. If you had problems with the Product class, contact the instructor for help in getting started.

  2. The name of the source code file must be store.cpp and all your code must be in this file.

    Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.

  3. Add a read() member function to your Product class that has no parameters and returns nothing. The read() function reads data from cin and loads it into the member variables of the Product object in the following order:
    1. name
    2. price
    3. quantity

    The read() function must operate like the following:

    Enter the name of the product: Baseball cap
    Enter the price for a Baseball cap: 12.59
    Enter the initial inventory: 42
    

    Notice that the user must be able to use spaces when entering the product name.

  4. Use a vector to store your Product objects and add at least three of the products from the previous assignment to the vector.

    Thus, your store will have at least three products defined when your program starts.

  5. Besides main() and the Product class member functions, define between three and eight non-member functions and call all the non-member functions at least once.

    A non-member function is a function that is not a member of the class.

  6. Your application must provide the following operations:
    1. Report on the inventory of current products, which includes name, price, quantity and value
    2. Add a product to the store using the read() member function of the Product class
    3. Delete a product from the store, which deletes the Product object from the vector
    4. Sell a product in the store, which decrements the inventory.
    5. Restock a product, which adds an amount entered from the keyboard to the current inventory
  7. Develop a menu to manage the operations of the store like the following and that operates like the example program:
    Please choose one of the following operations:
    0. Exit program
    1. Report inventory
    2. Add a new product
    3. Delete a product
    4. Sell a product
    5. Restock a product
    Choice (0-5):
    

    Note that the user enters the number to the left of the operation on the line labeled "Choice". Also note that entering a 0 exits the program. Do NOT change the number of a menu operation.

  8. Your program must follow the same sequence of inputs as the example program (see below).

    You must run the example program to understand the specifications. For instance, restocking a product asks for an amount but selling a product does NOT ask. Instead, selling always assumes one product is sold.

  9. Structure your code such that you declare function prototypes before main() and function definitions after main() for all your functions.
  10. Remember to follow all the style rules we have covered including:
    1. Class naming conventions (See: Class Names)
    2. Indentation in classes and placement of curly braces
    3. Every function declaration (prototype) in the class, including constructors, has a function comment block
    4. Every file has a file comment block
    5. No magic numbers (See: No Magic Numbers)
  11. Submit your files to Blackboard as explained in the section of this document: What to Turn In.

Example Program

You can see an example of how the program operates by downloading and running the executable file: store.exe. Note that you must run this example program from the command line on a Windows PC with Cygwin installed.

Hints

  1. For the menu, you can use a sentinel controlled loop with a conditional statements to select the operations. See Exercise 9.2.
  2. When adding a product name, do not forget about getline() and cin >> ws;. See lesson 6.1.5.
  3. To update a quantity:
    1. Ask the user for the position of the product in the store vector:
      cin >> position;
    2. Retrieve the Product object:
      Product temp = store[position]
    3. Use the getQuantity() and setQuantity() functions to update the quantity
    4. Save the Product object back to the same place in the vector:
      store[position] = temp;

Extra Credit

The following are worth extra credit points:

  1. Complete the assignment using pair programming. (1 point)
  2. Use your readDouble() function from assignment 6 to validate the numerical input of the read() member function. Your program must recover from an invalid entry. (2 points).

    Note: if your had trouble with your readDouble() function, you can correct it for this assignment. The instructor's solution is posted in Blackboard.

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.

Lesson Exercises

  • 2: All lesson exercises attempted and turned in
  • 1: Some lesson exercises completed and turned in
  • 0: No lesson exercises completed or turned in

Program Compilation

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

Program Functionality

  • 10: Demonstrates mastery of the assignment
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • Runs to completion with no abnormal error conditions
    • Generates correct output given correct input
    • Behaves in a reasonable way in response to incorrect data
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Attempts to meet 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
    • Attempts to meet 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
    • Attempts to meet 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
    • Attempts to meet 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

Program Style

  • 4: Code is well-documented including:
  • 3: Code has a minor documentation error
  • 2: Code has some documentation errors
  • 1: Code has many documentation errors
  • 0: No apparent attempt to follow documentation standards or write documentation comments

CodeLab and Other Tutorial Exercises

  • Number CodeLab completed correctly / number exercises * 8 and rounded up to the nearest integer.
  • -1 if the tutorial exercise file does not compile
  • -2 if the tutorial exercise file is not turned in

README.txt File

  • 2: README.txt file submitted following the instructions
  • 1: README.txt file submitted but some information was missing
  • 0: No README.txt file submitted

Total possible: 30, plus extra credit

What to Turn In

Submit your assignment to Blackboard, in the assignment folder that matches the name of this assignment, following the instructions for submitting homework. Include the following items for grading:

  1. README.txt file
  2. All the exercise files from Lesson 9
  3. store.cpp
  4. All the tutorial exercise source code files

You must submit all the files needed to complete your assignment. Do not assume that the instructors has any files. Your assignment must work as submitted.

Home | Blackboard | Day Schedule | Eve Schedule
Syllabus | Help | FAQ's | HowTo's | Links
Last Updated: May 09 2010 @22:29:56