se450_final_2017.docx

SE450 Final Winter 2016-2017 Section 801/810

Name: ______________________________

Directions: You don’t need to put your name on this exam unless you cannot upload the file to D2L. You may use your computer, blogs, notes, books, internet, etc. Don’t use people for help.

Q1 40

Q2 40

Q3 20

For submission of your exam submit only one zip file.

Inside this zip file submit:

--3 separate zip files for each of your projects

--10 point deduction if you do not meet this requirement.

--You do not need to submit the bin directory for your projects.

--Easiest way to create quickly create these zips is to right click on the project folder and use ‘send to’ compressed file. Open up the zip and delete the bin folder. Now copy these three zip files and the document into your ‘Final’ folder. Send it to zip file. Take that zip file and submit it to D2L.

You’re done!

Name: ______________________________

Question 1 (40pts)

Download the AllStarContest Template and import it.

Using the composite pattern finish the Shooter.java class. This is the only file you need to modify. You may not modify the other files.

Your class should use the composite pattern to rank higher and lower shooters. If a shooter has more points they should go into the ‘higher’ child node, if lower into a lower child node. They do not need to be lists.

You will also need to store makes and misses so you can output the winners made shots and the overall winner. Think about how you should do this.

Your class should store the Shooters name.

The simulation will randomly assign hit percentages on the balls and on the shot of each ball. Shots will be worth either 1, 2, or 3 points. Once you receive the shot object you can use instanceof to test if it’s a Make or Miss object. Here are the methods you need to complete

void addShot(Shot shot);

--Takes Shot object, figures out what it is and stores it accordingly

void rank(Shot shooter);

--Decides whether the shooter has more or less points and ranks them accordingly. Here is where you need to use your composite pattern. If you already have a ‘higher’ shooter you can pass it along to the ‘higher’ shooter to handle. Remember you have a tree and every node can decide to handle the ranking in its node or pass it on along to a child.

int rankShooter(Shooter shooter)

--Compares another ‘shooter’ with ‘this’ shooter object. Just like ‘compareTo’ method. A higher ranking is based off more scored points. In the case the point totals are the same you should then rank the one with more made shots higher. If the made shots are identically, you should then call ‘compareTo’ against the shooter and ‘this’ name property and rank them alphabetically from A to Z. This means that a shooter could make more shots but lose to a shooter that made less shots but more higher point shots. Ex: Player A makes 2 – 1pt shots for 2 total points but player B makes 1 – 3pt shot for a total of 3 points, thus beating player A.

//Overridden method

String toString()

--Prints in one string the entire Shooter tree. Highest shooters should be first in the string, then current shooter, then lower shooters. Again think composite (and recursion). Look at the provided output to make sure your output matches.

String getAllStartContestWinner()

--Prints the winner of the shootout and the shots they made. Again use the composite pattern. Your root node is not your winner per se. You should see if you have nodes that are ‘higher’.

Here is what your structure should look like.

The output should look like this:

//I will provide this top section of ouput (for all shooters, here I’m just showing one shooter)

Passing Ball #1 - worth 2 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #2 - worth 3 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #3 - worth 1 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #4 - worth 2 point(s) to shooter - Larry Bird

It was Made

Passing Ball #5 - worth 2 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #6 - worth 3 point(s) to shooter - Larry Bird

It was Made

Passing Ball #7 - worth 2 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #8 - worth 1 point(s) to shooter - Larry Bird

It was Made

Passing Ball #9 - worth 2 point(s) to shooter - Larry Bird

It was Missed

Passing Ball #10 - worth 3 point(s) to shooter - Larry Bird

It was Missed

//You will provide this output

Shooter: Jeff Hornacek scored 17 points and had 8 makes.

Shooter: Paul Pierce scored 13 points and had 6 makes.

Shooter: Stephen Curry scored 13 points and had 6 makes.

Shooter: Craig Hodges scored 12 points and had 6 makes.

Shooter: Voshon Lenard scored 12 points and had 6 makes.

Shooter: Peja Stojakovic scored 11 points and had 5 makes.

Shooter: Marco Belinelli scored 9 points and had 4 makes.

Shooter: Dirk Nowitzki scored 8 points and had 4 makes.

Shooter: Eric Gordon scored 8 points and had 4 makes.

Shooter: Glen Rice scored 8 points and had 4 makes.

Shooter: Kevin Love scored 8 points and had 4 makes.

Shooter: Larry Bird scored 6 points and had 3 makes.

Shooter: Jeff Hornacek is the All Star Contest Winner.

  He scored 17 points.  He made baskets on shots:[2 (3)][3 (1)][4 (2)][5 (2)][6 (3)][7 (2)][8 (1)][10 (3)]

Name: ______________________________

Question 2 (40pts)

Download the Automated Salad Order Template and import it.

Using the Chain Of Responsibility pattern create four classes in separate java files. LeafDispenser, CheeseDispenser, DressingDispenser, and ToppingDispenser and finish the salad method in the AutomatedSalad class.

This simulation will simulate 10 salad orders from customers. An order can consist of leaf, cheese, dressing, and topping to create a salad. The customer can double an item such as leaf, or cheese, or they may skip one of the items all together. An order will consistent between one and eight items in any combination, with no more than two of each item. Selections within items could be chosen twice. Ex: Customer wants Kale and Italian and Italian.

Leaf can be: Bok Choy, Chard, Iceberg, Kale, Romaine, or Spinach

Cheese can be: American, Asiago, Cheddar, Hot Pepper, Mozzarella, Parmesan, or Swiss.

Dressing can be: Buttermilk, Catalina, Cesar, Italian, Ranch, Thousand Island, or Vinaigrette.

Toppings can be: BaconBits, Croutons, Eggs, Tomatoes, SesameSeeds, Raisins, Onions, Cucumbers, Beets, Chicken, Ham, or Tuna.

The items for each time can be found in their respective ‘item’ file. Ex: LeafItem.java for the above Leaf types.

Your four ‘dispenser’ classes must extend Automation class. They only need to override and implement the processInput method. Inside processInput you should print out the proper information to match the provided output below. To help you along, your classes will need to hold a reference to the ISaladItem that you should pass into their respective constructors which processInput can use. You must declare the reference and have it declare with an initial reference to NullItem until you ‘hook’ it up. This is worth 5 points!. It will also help you understand one of the many uses of the Null Pattern. You will also need to hook up the processInput method so it continues on in the chain by calling its super class accordingly.

The last part is to finish the salad method and create the ‘processing chain’ in AutomatedSalad.java. I would recommend you have a reference to a ‘pipeline’ interface of IAutomation that will initially serve as the head of the processing chain. To set it up properly its easiest to reverse iterate the ArrayList of Orders you receive. As you iterate the arraylist of orders, set the new ‘machine’ objects output to the pipeline then set the pipeline to the machine interface. This way when you are done you’ll be holding the pipeline as the first input machine. Next you need to ‘process the input’ so it matches the output provided.

**To reverse iterate a SaladItem array use ListIterator. When you get the listIterator set its parameter to the size of your arraylist. Then call hasPrevious and previous rather than hasNext and next.

//You will provide thie 10 salad order with the following (example) output

Assembling Salad-->[TOPPING:Beets][DRESSING:Cesar][CHEESE:American]-->Salad Assembled

Assembling Salad-->[DRESSING:Ranch][CHEESE:Asiago][LEAF:Romaine][CHEESE:Cheddar][TOPPING:Raisins]-->Salad Assembled

Assembling Salad-->[CHEESE:Cheddar][LEAF:Spinach]-->Salad Assembled

Assembling Salad-->[TOPPING:Ham][CHEESE:Cheddar][DRESSING:ThousandIsland][LEAF:Iceberg][LEAF:Romaine][TOPPING:SesameSeeds][DRESSING:ThousandIsland][CHEESE:HotPepper]-->Salad Assembled

Assembling Salad-->[CHEESE:Mozzarella][DRESSING:Ranch][TOPPING:Tuna][LEAF:Chard][LEAF:Romaine][DRESSING:Buttermilk][CHEESE:Swiss]-->Salad Assembled

Assembling Salad-->[CHEESE:HotPepper][LEAF:Kale][TOPPING:SesameSeeds][DRESSING:ThousandIsland][DRESSING:Italian][CHEESE:Asiago][LEAF:Romaine]-->Salad Assembled

Assembling Salad-->[LEAF:Chard][DRESSING:Buttermilk]-->Salad Assembled

Assembling Salad-->[LEAF:BokChoy]-->Salad Assembled

Assembling Salad-->[CHEESE:Parmesan][LEAF:Romaine][CHEESE:American][LEAF:Kale]-->Salad Assembled

Assembling Salad-->[LEAF:BokChoy][CHEESE:Parmesan][DRESSING:Vinaigrette][LEAF:BokChoy]-->Salad Assembled

Name: ______________________________

Question 3 (20pts)

Download the Immutable Template and import it.

Finish the ImmutableMirroredInteger.java class. Make sure its Immutable and follows all the rules lined out in lecture notes. Follow the comments inside the code. You cannot modify the MutableMirroredInteger.java. I have added asserts to the code to help you verify your class works. See the notes for including this in compilation if it’s not working for you.

Shooter 1

4 Points

2/4 Made

Shooter 2

3 Points

2/4 Made

Shooter 3

1 Points

1/4 Made

Shooter 4

6 Points

3/4 Made

Miss

Shot 1

Made

Shot 2

1 pt

Made

Shot 3

3 pt

Made

Shot 4

2 pt

Example:

4 Shooters

4 Balls

Shooter 1 4 Points 2/4 Made Shooter 2 3 Points 2/4 Made Shooter 3 1 Points 1/4 Made Shooter 4 6 Points 3/4 Made Miss Shot 1 Made Shot 2 1 pt Made Shot 3 3 pt Made Shot 4 2 pt Example: 4 Shooters 4 Balls