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
  • Store objects in arrays

Specifications

Write a Store class that loads 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.java starter code to begin development.

Sample Operation

  1. The program displays a welcome screen.
  2. Program start

  3. After this, you can select a product to buy.
  4. Show inventory

  5. If you choose a product that is not listed, you get an error dialog like this:
  6. Items to sell

  7. After pressing the OK button, you have another chance to select a product.
  8. Show new inventory

  9. After you select a product, the inventory changes as shown:
  10. Show updated inventory

  11. Pressing the Cancel button at any time exits the program.
  12. Show updated inventory

Required Methods

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

/**
 * Constructs a Store.
 */
Store() throws IOException

/**
 * Load the product information from the fileName into prods[].
 */
public void loadProducts() throws IOException

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

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

Additional Specifications

  1. The name of the program application file must be Store.java.
  2. The name of the file that initializes the store must be products.txt.
  3. Your program must read a products.txt file in the following format
  4. Whenever the user presses the Cancel button, the program exits.
  5. Cancel message

  6. Your program must catch and handle all user-input error conditions.
  7. Error checking message

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

The following are worth extra credit points:

  1. Complete the assignment using pair programming. (1 point)
  2. Format the prices so they display as dollars and cents. (1 point)

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.java
  3. Store.java
  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 | Schedule | Expectations | Course info
Help | FAQ's | HowTo's | Links

Last Updated: December 04 2004 @11:42:04