Project 4

Due: Mon., April 9, 8 AM
Submit Project: Proj4
Required Files: Proj4.java
Grading Header: header.txt
Test data: testa.dat
Model Output: out.dat

Moving on with our new found skills, it's time to write a program incorporating the looping structures we've learned. Of course, we will build on old information too, incorporating into our program other structures like the if and switch statements as well as method creation and calling. There is only one file for this project, therefore the extra methods that you create must all be static methods. We will also define a few static variables. Arrays can NOT be used for this project.


Program Description

With this program you are going to keep track of the inventory of the Clipper Manufacturing Company (CMC). CMC manufactures five products:

  1. Bicycles
  2. Unicycles
  3. Mopeds
  4. Skateboards
  5. Skates

CMC's warehouse has room for only 50 of each item. There is never a negative number of any of the products. CMC would like you to write a program to keep track of the number of each product in the warehouse. Your program should be able to display the amounts in a bar chart along with the number in the inventory for each product.


Project Specifications

Write a program that implements this inventory program.

  • Place all code in a file named Proj4.java.

  • All code must conform to the style guide in formatting and comments. Don't forget that every method must have a javadoc prologue which includes @param and @return tags if appropriate.

  • You should define 5 global static variables (inside the class but not inside main) which should be the number of bicycles, unicycles, mopeds, skateboards, and skates that the company has on hand. In addition there should be 1 static constant, MAXITEMS, which should be set to 50.

  • Within main, declare a Scanner object. There should only be one. Pass this as a parameter to the appropriate methods as needed.

  • The program should be a menu driven program. Within main, you should continually print a menu and get a response for what option the user would like to perform next. The menu should look like the following:

    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph the current items stored in the warehouse.
    Q) Quit
    
    

  • The user should be allowed to enter a response. Don't forget to echo-print.

  • If the response above is 'A' or 'R', another menu should print that asks for which product's inventory is to be affected. This menu should look like:

    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) Skates
    
    
  • The user should be allowed to enter a response. If this response is incorrect, (less than 1 or greater than 5), this menu should be repeated until a valid response has been entered. Again don't forget to echo-print.

  • Then the program should call upon the proper method to do what has been asked. (Use a switch statement here.) (The first three responses should each have an individual method that carries on the appropriate activity.) So if the user enters:

    Output Specifications

    A program run might look like the following (don't forget to echo-print all input):

    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: a
    a
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) Skates
    
    Choose an item number: 1
    1
    
    Enter quantity to add to inventory: 20
    20
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: a
    a
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) Skates
    
    Choose an item number: 3
    3
    
    Enter quantity to add to inventory: 10
    10
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: a
    a
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) Skates
    
    Choose an item number: 1
    1
    
    Enter quantity to add to inventory: 40
    40
    *** ERROR: maximum items exceeded ***
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: r
    r
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) Skates
    
    Choose an item number: 3
    3
    
    Enter quantity to remove from inventory: 15
    15
    *** ERROR: Cannot remove that many items ***
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: G
    G
    
    Item         Number     Chart
    Bicycle      20         ********************
    Unicycle     0
    Moped        10         **********
    Skateboard   0
    Skates       0
    
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: A
    A
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) skates
    
    Choose an item number: 6
    6
    
    Illegal item number entered.
    Please try again.
    
    1) Bicycle
    2) Unicycle
    3) Moped
    4) Skateboard
    5) skates
    
    Choose an item number: 5
    5
    
    Enter quantity to add to inventory: 10
    10
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: P
    
    An illegal option has been entered.
    Please try again.
    
    *** CMC Inventory System ***
    
    A) Add to an item's inventory.
    R) Remove from an item's inventory.
    G) Graph current items stored in warehouse.
    Q) Quit.
    
    Enter choice: Q
    Q
    
    Thank you for using the Inventory Control System.
    


    Specifications for Documentation and Format

    With the help of the Style Guide in your Lab manual, fully document your code following the javadoc conventions for prologues and include:


    Program Testing and Submission

    Information needed for testing this program are linked from the top of the page. Test your program thoroughly with the data and sample output given before submitting.

    Submit your program file electronically: In Eclipse, right click on the project and import the files from /home/f85/debbie/cs141/Proj4. Right click on the file submit.xml and select Run -> 1 Ant Build; Messages will appear in the Console window. Be sure to determine whether you got the Build successful message to ensure that your electronic file submission for this lab was successful.

    Honor Code. The honor code applies to all programming done in this course. Reread the CS Department's document: Programming Assignments and the Honor Code.


    Debbie Noonan, debbie@cs.wm.edu
    March 20, 2007