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. You can look at solutions if you miss your first attempt.

  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:

    Complete the Tutorial Exercises listed below.

Program Specifications

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 variables to or remove any of the required functions from the Product class.

  2. 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.

  3. Use a vector to store your Product objects.

    Use at least three of the hard coded products from the previous assignment to the vector storing products. Thus, your store will have at least three products defined when your program starts.

  4. 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.

  5. 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
  6. 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.

  7. Structure your code such that you declare function prototypes before main() and function definitions after main() for all your functions.
  8. 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.

  9. Your program must follow the same sequence of inputs as the example program.
  10. Make sure that every function declaration (prototype) has a function comment block. In addition, remember to include a file comment block and follow all the other style rules we have covered.
  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.

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 3.2.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. Validate the input of the read() member function of Product, using techniques described in lesson 6.1.3 , lesson 6.1.4, and lesson 6.1.5. The program must recover from an invalid entry. (2 points)
  3. Validate the input of the non-member functions to ensure that only integer numbers can be entered and that the program recovers from an invalid entry. (2 points)

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

Tutorial Exercises

  1. Type the following programs from the textbook on pages 436 through 440 into a text editor, and then compile and run the programs. When they are working, submit them to Blackboard for grading. Make certain you use the same file name as the program name.
    1. maxval1.cpp
    2. maxval2.cpp

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

  • Starting with 8 points
  • -0.286 points for each CodeLab exercise not completed correctly
  • -1 if the maxval1.cpp file does not compile
  • -2 if the maxval1.cpp file is not turned in
  • -1 if the maxval2.cpp file does not compile
  • -2 if the maxval2.cpp 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 | Announcements | Day Schedule | Eve Schedule
Course info | Help | FAQ's | HowTo's | Links
Last Updated: April 23 2009 @15:53:44