CS 1083 -  Fall 2019 -  Project 3:   Supermarket Transaction Using Dynamic Window

(100 points)

The SupermarketDynamicWindow Class

Objectives

This is one of three major programming projects this semester.  You may NOT collaborate on this project.  While you may ask for assistance in debugging, this project should be ENTIRELY your own work.

Other objectives include:

Hand-in Requirements

All projects will be submitted electronically through Blackboard.  Zip up your entire lab directory to submit as the source.  (Right click on the lab folder and follow the 7-Zip > Add to "abc123_project3.zip" or follow Send To > Compressed (zipped) Folder.)  The lab folder should include the following:

Introduction

The goal of this project is to code the missing parts (methods) of a program that allows the user to process a supermarket transaction in a graphical way.   This version will be programmed as if the application was going to be deployed for a tablet.   The most interesting part of this project is experiencing the re-use of code.   Calling methods with different parameters allows the programmer (a.k.a. the student) write programs with less lines of code while also organize the funtionalities.  

This project is similar to the project 2.   For instance, the method getValueList performs the same functionality than getValidInput in Project 2.   Moreover, both methods are in charge of getting values from the user.   The difference now is that we need to get the information in a graphical way.   That said, the program will not send anything to display in text mode rather than through the DrawingPanels.

Just like for the project 2, in this exercise you act as if you were part of a software development team.   In other words, when working in that environment, you need to use/code each and every method provided as method stubs.   The reason for that is that if you don't work with the methods provided the complete team project will fail when tests will take place. 

Note: Do not pay attention to the tittle of the DrawingPanels.   Specifically where it says "@fox05".

As a recommendation, try to start working with enough time in advance given that this project may take a good amount of time to accomplish it.

Details

The program will start with the method genTransaction, which will perform the following tasks.

The Cart

In the previous project, all the arrays were static.   In other words, they did not change in size or values throughout all the program execution. Nonetheless, in this project we introduce the concept of a shopping cart.   The cart  stores information in two arrays cartItem and cartQty.   These arrays have a capacity to hold MAX_ITEMS items.   However, the actual number of items can be less than  MAX_ITEMS  and will be recorded in the variable cartSize.

Initial Zip File

You should start your project by downloading abc123_project3.zip.  This file contains DrawingPanel.java file and a template SupermarketDynamicWindow.java file.

DrawingPanel.java

The DrawingPanel.java has been updated to include two additional methods for getting mouse click positions.  Here are the methods you may use.

Method Name Description
getGraphics( ) returns a Graphics object that the program can draw on
setBackground(color)     sets the background color
sleep(milliseconds)  pause for a given number of milliseconds (1000 milliseconds equals one second)
close( )  closes the window
getClickX( )  returns the X position of the last mouse click
getClickY( )  returns the Y position of the last mouse click

See the provided getDecision() method in the SupermarketDynamicWindow class for more details on how to use these methods. You should model your implementation of your getValueList method after the sample code provided in the getDecision().

SupermarketDynamicWindow.java

The template version of SupermarketDynamicWindow.java already implements the following pseudocode which you should not change:

In the main method:

  1. Asks to the user to confirm if a new transaction should be started.
  2. If yes, it will call the genTransaction method.

In the genTransaction method:

  1. Asks to the user to confirm if a new transaction should be started.
  2. If yes, it will call the genTransaction method.
You should start coding right after this, following the instructions provided in the Details section.

You should study the code in SupermarketDynamicWindow.java to gain an understanding of how the code implements the aforementioned behavior. Pay attention to the description of what is stored in each variable. For the getClickRowExample and getClickColExample methods, determine the correspondence between the return values and locations of the mouse clicks.   Figure out how the program knows which rectangle is selected in a particular cell labeled by "Yes" and "No".

You should then start coding the functionality described in the section Details.   Study the detailed documentation of what is each method purpose (functionality) and the details about parameters and their possible values, and what will be returned by the method.

Change to receive an array of options

For this project, you need to code the missing parts in all the code which intends to work with dynamic windows which will change size and options possible toselect based on the array that will be received as parameter.

The program should be modified to ensure that it implements the behavior that will be seen in the videos provided in the next link.

Rubric

Your program should compile without any errors.  A program with more than one or two compile errors will likely get a zero for the whole assignment.

The following criteria will also be used to determine the grade for this assignment: