CSc 331 - Spring 2018
Lab Exercise #7

Preparation

Additional Information / Guidelines

Exercise 1

(Question 1(f) from the midterm test.) Suppose that we have the need to clone Shopping Carts.

public ShoppingCart {
    private String owner;
    private ArrayList<Die> items;
    …

Write the code for a clone method that creates a “deep enough”. I have changed CartItem's to Die's since we have already cloned Die's in class. Recall that ArrayList’s are cloneable.

I have supplied a simple test main.

Exercise 2

Just for comparison, let's do the same thing with copy constructors instead. (You will need to write a copy conmstructor for Die.) To execute your copy constructor, just add a few lines to the main from Exercise 1.

Exercise 3

Start building a GUI for your Craps code.

You can often create either anonymous objects - or named instances - for JavaFX nodes. It would be prescient to use named instances for those nodes which might have require EventHandler's in Lab Exercise 8.

Note: for the "root" node (perhaps a VBox instance) of your scene graph, you will probably want to do something like "root".setMinHeight(400) to accomodate your player boxes.

Suggested layouts will appear here soon. (or not!) When you are in the lab7 directory, you should be able to java CrapsGuiSwing to produce a "prettier" version of a suggested layout for 2 players. java CrapsGui2 will produce a "needs work" version to which you can add players.

Submit:

This assignment is due at the beginning of the Tuesday lab class in 2 weeks (March 27) at 3:30 p.m. - and the submit program will enforce this.