CS 280 Spring 2009                           Assignment 4 – Using Existing Non-Built-In Classes  - PizzaStore       100 “Assignment” points

 

Assigned: 02/11/2009

Due: 02/19/2009 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Plan out your GUI, tasks, objects, and events needed for program. Download, unzip and familiarize yourself with the Classes that I’m providing. Plan out how you will solve the problem.

 

Main Assignment:

Imagine that you are writing some parts of a Home Baked Pizza store simulation program.  We are still a bit away from being able to do the full job, so pay attention to what I’m asking for. Also note that you will need to gain an understanding of the provided classes. The provided classes will be in a zip file on Blackboard, along with documentation for the classes.  A quick introduction is included below. You will neeed to declare a PizzaStore object as an instance variable in your  GUI class so that it is accessible from all of your buttons.  You should also instantiate it immediately so that the user doesn’t have to Click the Reset button before starting. You should create buttons to:

1.  Customer buys pizzas – the pizza store object needs to provide the service – call the capability provided by the class. Note that we have not yet covered branching; in my example the message box has just shown the Boolean returned by a method. Booleans are a primitive type that can have the value true or false.

2.  Store re-orders batches of pizzas – the pizza store object needs to provide the service – call the capability provided by the class.  The size of a batch is declared in a constant in the PizzaStore class. However, the only reason you might to know it is for debugging – knowing if the pizza store has the correct number of pizzas in inventory.

3.  Restart the simulation – clear the input text fields, hide the results panel, and reset the pizza store object (re-instantiate it).

4.       Display the current status of the pizza store – get info from the pizza store object. Show the results panel.

5.       Exit the program

 

Background Knowledge:

 

User Interface:

·         You’re just a beginning at setting up GUIs in NetBeans. Don’t worry too much about making the interface nice.  See my simple sample interface below – Don’t let that constrain your creativity. Use it to help understand what I see as inputs and outputs. The version of the assignment on my www site includes more pictures (“screen shots”). The version on Blackboard may not include any.

·         I strongly recommend that you put all outputs on an output jpanel. This will allow the reset button to hide all of them with one statement, and the display button to unhide all of them with one statement.

·         DO put your name on the GUI form either as a label or on the title bar.

·         You are not required, but are encouraged to use number formatting to display money as currency (I did not in the screen shots)

 

Miscellaneous Details:

o    Make sure you read the documentation on the PizzaStore methods so you know exactly how to use them. It is provided as Javadoc documents, which are html files that can be found inside the project folder included in the zip.

 

Good Programming Practices:

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results).  It must provide all of the requested capabilities AND provide them in the expected way.  

·         Put YOUR NAME, e-mail address, and purpose of the program in comments at the beginning of the program (Netbeans should also automatically put in the date – which is also a very good practice). The purpose should be what the program is supposed to do, not the learning goals.

·         Name meaningfully all jbuttons, jtxtfields, jlabels, etc that will be referred to in code.

·         Indent to show any structure of the program (The IDE usually does this well if you don’t go back and change things – probably not much to worry about on this basic of a program)

·         You MUST include some comments that expain your program in order to get full credit; for this simple program put at least one comment for each button..

 

Red Tape to Aid Grading:

·         Please set the name of the project to something other than the default name (JavaApplication1, …). 

·         Add  your name in a jlabel on the GUI form  and/or in the title bar.

 

Hand in:

 

Do your own assignments !!!!  Work that is copied or done with somebody (when not assigned to a group) will be punished. If programs are copied, both students will receive a zero for the assignment. If significant sections of programs are copied, points will be taken off. Changing small aspects of a copied program does not make it not a copy. Asking another for help on a step or two in a many-step assignment is acceptable; looking at another person’s program is temptation for cheating; handing in a near duplicate program is cheating

 

Provided Classes:

 


Sample Interface:

 

On Startup

 

Trying to buy non-existant pizzas:

 

 

Message (no branching):

 

 

Reorder Inventory by the batch:

 

 

Message:

 

 

 

 

 

 

 

 

 

Now can buy successfully:

 

 

After  some successful buys, display results:

 


Restart: