CSIS1275-01 JAVA Assignment 3 (12%) Winter 2009 Due date: Mar.

31st/2009 You can do this assignment with one partner, in which case, hand in one piece of work with both your names on it. Create a Java Applet using Java Swing components and layout managers, call it MovieBuy.java, that will allow customers to select a movie to purchase. It should have the following functionality and layout : Main Screen The initial main screen is as shown on the next page. Layout Ensure that the layout of the main screen remains the same, whatever the size of the applet (i.e. use layout managers)

NOTE: The default is DVD for the radio button.

Functionality

1.

The user first clicks the on button

(JButton with image). Once clicked on, it will then display the movie data in their

respective JList boxes, i.e.: (please see last page to see where the data is from), so initially, these JList boxes are blank, until the button is clicked. Note, ONLY the “Movie Titles” JList box is selectable, and is single-selectable).

2.

The user will then select a movie, i.e. . The program will automatically highlight the DVD/blu Ray stock in their respective colours (green for DVD, yellow for blu Ray) for that movie title.

3.

The user will now select whether to get a DVD or blu Ray and how many copies, i.e.: . Here the user has chosen 2 DVDs at $19.99. Note, the DVD and blu Ray prices are displayed using JLabels (the DVD/Blu ray prices cannot be changed here)

4.

The user than clicks the Buy button

(JButton with image). If everything is fine, then it will display in the JList box

(Movie selected JList box with scrollbars). The total will appear as shown in the total

JTextField (It should also have a cyan background and is READ ONLY):
5.

Note also, that the JList boxes should automatically be updated with the current quantity for DVDs and blu rays for that movie title, i.e.: (as you just bought 2 DVDs of Star Trek, you now have only one DVD left for that title). Remember, this is done automatically as soon as the “Buy” button is clicked (i.e. you don’t have to click on the movie title to see the new totals)

NOTE: If the user clicks on the

, but NO movie was selected in the “Movie Title” JList box, then the following warning box

appears:

6.

The user can select as many movies to buy (as long as there is stock available) i.e :

The total amount accrued so far is then displayed in the total JTextField next to it. This basically keeps a running total.
7.

The user can now if he/she so wish, enter the credit card number (NOT an actual one of course) and click the submit button, i.e.:

(Note the credit card field must be a JPasswordField)

A warning box appears, i.e.: If the user clicks “Yes” then appears. Clicking on “Ok” will clear the Movie Selected JList box, Total and the credit card field, i.e.:

If the No button or close button is clicked, then NO action is taken (assuming the customer wants to purchase more).

If there are NO movies selected for purchasing, but the customer still clicks on the “Submit” button, then after the usual “ Are You Sure Yes/No”dialog

box, it should display

.

If user clicks “Submit” and there are movies selected for purchasing but did NOT enter a credit number, then after the usual “ Are You Sure Yes/No”

dialog box, it should display Not Enough to Buy

.

If the user selected the following: , i.e. buy 2 blu Ray of Star Trek, but there are no blu ray discs available, then the following should be displayed, when the Buy button is clicked:

Similarly, if the user selects to buy 4 DVDs of Star Trek, and there are only 3 DVDs available, then the following should be displayed, when the “Buy” button is clicked.

Clear and Clear All Button

The Movie Selected JList Box is single-selectable, i.e. any of his/her selections before actually buying the movies. Once the movie to remove is selected, the user can click the

. Here

the user can remove

button, in which case the selection will be deleted from the JList box with the Total JTextField updated i.e. the amount should be reduced. to , i.e. it should keep a running total. NOTE, if the user continues to clear every selection in the Movie Selected JList box, then the total eventually should be 0.00. ALSO, as soon as the “Clear” button is clicked, the number of DVDs/Blu Rays should be updated, i.e. in this case, as the user wants to remove 2 blu Ray discs for X Files 2, then as soon as “Clear” is clicked, the blu Ray stock for X Files 2 should be replenished by 2, that is: . Similarly, if the user wants to remove the 3 DVDs for X Files, then the DVD stock for X Files 2 will be back to 34. If the Clear button was clicked BUT NO movie selected, then the following error box should appear.

.

If the

button is clicked then a warning box such as

is displayed. If user clicks on Yes button, then ALL the movies selected will be deleted from the Movie Selected

JList Box, with $0.00 displayed in the Total JTextField. ALSO make sure the DVD/Blu Ray totals have all been replenished as well and displayed in their respective JList boxes, as soon as “Yes” button is clicked. If the No button or close button is clicked, then NO action is taken.

Update

This is an alphabetic keypad, where employees can enter a password by clicking on the keypad on the keyboard). If the next page for details).

(i.e. NOT entering

button is clicked and the correct password was entered, then it will go into the Movie Update window (please see

When clicking the password on the keypad, make sure that it is masked out i.e. . The password can be any number of characters, which I leave up to you. You can “hardcode” the password into the program. If user enters the wrong password, then the following error box should appear:

. The merely clears the password field (just in case you entered the wrong password and want to restart).

Upon entering the correct password it should first clear the movie title, DVD/blu Ray stock JList boxes and the price JLabels, i.e.:

then the following Movie Update window appears.

Movie Update Window (Save this part as UpdateFrame.java) Upon entering the correct password, this will generate a window with the following layout and components. Note, this window is resizable BUT the layout should remain the SAME, whatever the size of the window, i.e. use Layout Managers.

Functionality

Movie JTextArea, with scrollbar

JTextField

Here the user can change the DVD/Blu Ray stock and their prices. The user first select the movie from the Movie pull down box, i.e.

. The current movie details i.e. it’s stock, will be displayed in their respective components, i.e.

The user can change the stock for DVDs or Blu Rays by first unchecking their respective “Lock” check box. Then the user can either enter the new stock value into their respective textfield or by dragging their respective JSlider. Please note, that the maximum is 100, so even if you manually enter more than 100, the value of 100 should be displayed. A stock of “0” is the minimum. If the user manually enters “25” and then presses the <Enter> key, then the JSlider should automatically go to 25 on the JSlider i.e.

If the user manually drags the JSlider, then the JTextField should automatically display the new value as you drag along. This behaviour applies to blu Ray side as well. Once the “Lock” checkbox is checked again, then both the JSliders and the JTextFields will not be selectable. The prices can be changed by entering directly into their JTextFields. Note, these prices apply to all DVD and Blu Ray titles, i.e. each movie DO NOT have their own prices. The 19.99 DVD price applies to ALL DVD movies. The same applies for the Blu Ray price)

. HOWEVER if the user accidentally enters more that 2 decimal places, i.e. he or she enters 45.7892, then it will round to 45.79 and that will be the price displayed in the text box and used in subsequent calculations.(Hint: first convert to double, use DecimalFormat twoDecimal = new DecimalFormat("0.00"); to round to 2 decimal places and then resave back. Once you are satisfied with all changes, then the button MUST be clicked. The following confirmation dialog box should

appear 15).

. Note, the changes made here, MUST then be reflected in the previous main screen (see page

Movie List Menu

This should have the above selections and corresponding mnemonics. • If the user selects Full List , then it should display in the Movie JTextArea, a full list of all the movies and their current stock i.e.

(Note, the font is Helvetica, bolded, italics at 14pt) AND HAVE a

scrollbar available If the user selects Clear , then it simply clears Movie JTextArea

Exiting Movie Update

Ensure also the following buttons

do work with this window.

Note: It is important that when the user exits from this Movie Update screen and returns back to the main JApplet, the following are blank.

The user MUST then click

to display the movies and the new values, i.e:

. You can see that the DVD price and blu Ray stock for Star Trek has changed. Finally, create an HTML file ( call it MovieBuy.html) to hold this applet. The background should be a sky background utilising the sky.gif file.

Note the top part with you actual name.

is from the HTML file. Please replace

Classes You must create at least 2 classes to start off with. These classes are in “MovieInfo.java” which will be given to you.

What to Hand in 1. Front cover page with your name, course, assignment number, instructor’s name and due date 2. Hardcopy of the program listing 3. Zip up and Save as csis1275Assign3YourName.zip and either File Submission (myDouglas) or E-mail (myDouglas) or burn to CD for the .java files, any picture files and the HTML file. 4. The for the Movie Update. MARKS WILL BE LOST IF ANY OF THE ABOVE IS NOT MET OR IF THE DISK IS NOT READABLE OR PROGRAM NOT COMPLIABLE.

password