CS 157 Spring 2002                       Assignment 11 Constructors, Static Methods                     100 points

 

Assigned: 04/25/2002

Due: 05/03/2002 at the start of final exam. 

Pre-Lab (Do Before Lab): Create a plan for all code to be created – in Cookie class, Static I/O, and main. Bring an empty (or nearly empty) disk. 

Main Assignment:

                Mrs. Fields Cookies has decided that they’d like you to help out with running their stores. I have provided most of a class definition for Mrs. Fields (on my WWW page), which will keep track of inventory, number of cookies sold, and profit margin, and enable selling cookies. You need to provide non-default constructors for the class for this assignment. You will also write static, overloaded methods in order to read valid input in from the user. You should use the GUI style interface. You will also write a main function that simulates customers coming to the store, “Write code for main that asks the user for the number of cookies in initial inventory, the profit margin for cookies, and the number of customers to process; then processes customers until all customers have been processed (or there are no more cookies), and for each one, ask the customer for the number of cookies, and sell them if you can. (If there are not enough cookies for the customer’s order, they should be given a choice as to whether they want to accept a partial order. A customer who answers No cannot be served and is skipped and we move on to the next customer.  After all customers have been processed, (and as many customers have been served as possible), report the number of customers actually served and the total profits for the day.”

      Since all output goes to GUI dialog boxes, I was unable to capture output from the system as an example. If you have any questions, please ask. 

 

Hand in:

Miscellaneous:

·         I want you to use dialog boxes instead of SavitchIn. See examples from class.  

·         When validating, initial inventory can range from 1 to 1000; profit margin can range from 0.01 to 5.00; and number of customers can range from 1 to 100; and a given customer can order from 1 to 200 cookies.

·         This assignment is focusing on static functions and constructors. WRITE THEM AND USE THEM. You MUST use a non-default constructor in main for this assignment (it is one of the points of the assignment).

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). 

·         Put YOUR NAME, and e-mail address in comments at the beginning of each file.

·         Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit. EACH method must have comments appropriate for javadoc.