Question
Please create a java program of following question: The famous character Forrest Gump from the movie of the same name had it right: Life is
Please create a java program of following question:
The famous character Forrest Gump from the movie of the same name had it right:
"Life is like a box of chocolates, you never know which one you're going to get unless you use Java's instanceof keyword".
This exercise demonstrates your understanding of double dimensional arrays, type upcasting/downcasting and the use of the instanceof keyword. Refer to "The Well Made Clock" example available in the course materials section.
The Task: You have a box of chocolates consisting of 10 rows and 10 columns for a total of 100 chocolates obtained from Rocky Mountain Chocolate Confectionery (http://www.rockychoc.com/our-treats/). For each of these 100 spots, your program must randomly choose from a set of eight delicious treats to place in each of these spots and then REPORT on which treat is in which box based on four different 10x10 grids. The required output is explained in detail below.
This assignment consists of two parts.
Part I: The UML diagram. Click here for an example of the UML diagram you must create. Your UML diagram must begin with BoxOfChocolatesDriver, BoxOfChocolatesSimulation, and OurTreats classes as the first level of your UML hierarchy. For the second level, you must choose KettleMade and Chocolates TYPES of treats same as the supplied example UML diagram. For the third level, you must choose four CATEGORY of treats OTHER THAN the ones that the sample UML diagram shows (i.e: choose any four EXCEPT FOR Apples, Brittle, Creams, and Clusters). For this category, you must choose TWO from KettleMade and TWO from Chocolates to make up your four. From this CATEGORY level of the hierarchy, pick two treats from each of these categories (see example UML diagram as a guide). This will result in your set of eight treats that are to be randomly placed in your box. Finally, for each of these eight treats, you must create ONE interface class that represents an ingredient that is used in that treat. In the example, Apple is an ingredient(interface) to PlainCandyApple. Likewise, Caramel is an ingredient to PlainCaramelApple. Do not guess on the ingredients, the website lists the ingredients for the treats. This will complete your UML diagram.
Part II. The Program. Your program must create 4 different views of the 100 treats in your box. For each of these views, you MUST use the Java instanceof keyword to identify the type, category, and treat. The view must be in a 10x10 matrix view. Here is an example of the first view. Position AA is equal to 3 which means the treat in this box position is "Ginger Cluster".
TREATS IN THE BOX
0=Plain Candy Apple, 1=Cashew Brittle, 2=Chocolate Butter Cream, 3=Ginger Cluster,
4=Peanut Cluster, 5=Coco Loco Cream, 6=Chilli Garlic Peanut, 7=Plain Caramel Apple
A B C D E F G H I J
----------------------
A | 3 4 4 5 5 7 4 0 5 2
B | 0 1 7 2 1 3 4 2 0 4
C | 2 5 2 7 1 7 3 2 1 6
D | 4 6 3 7 2 6 1 1 5 6
E | 3 3 3 7 0 7 3 0 4 2
F | 4 6 3 3 1 7 4 7 6 6
G | 2 7 2 0 6 4 1 4 0 1
H | 4 5 5 2 1 7 5 7 0 6
I | 0 1 4 3 7 3 5 4 5 1
J | 5 4 0 0 3 4 0 4 0 5
In the second grid view, you are to show which compartments in the box are of one of the four categories. In my example, the treat categories are: Apples, Brittle, Creams and Clusters. In the example below, position AA shows the category of that treat is Clusters.
TREAT CATEGORIES
0=Apples, 1=Brittle, 2=Creams, 3=Clusters
A B C D E F G H I J
----------------------
A | 3 3 3 2 2 0 3 0 2 2
B | 0 1 0 2 1 3 3 2 0 3
C | 2 2 2 0 1 0 3 2 1 1
D | 3 1 3 0 2 1 1 1 2 1
E | 3 3 3 0 0 0 3 0 3 2
F | 3 1 3 3 1 0 3 0 1 1
G | 2 0 2 0 1 3 1 3 0 1
H | 3 2 2 2 1 0 2 0 0 1
I | 0 1 3 3 0 3 2 3 2 1
J | 2 3 0 0 3 3 0 3 0 2
In this third grid view, you determine the type of confectionary of each treat. In the example below, position AA is 1 meaning the treat is of type Chocolates.
TYPE OF TREATS
0=Kettle Made, 1=Chocolates
A B C D E F G H I J
----------------------
A | 1 1 1 1 1 0 1 0 1 1
B | 0 0 0 1 0 1 1 1 0 1
C | 1 1 1 0 0 0 1 1 0 0
D | 1 0 1 0 1 0 0 0 1 0
E | 1 1 1 0 0 0 1 0 1 1
F | 1 0 1 1 0 0 1 0 0 0
G | 1 0 1 0 0 1 0 1 0 0
H | 1 1 1 1 0 0 1 0 0 0
I | 0 0 1 1 0 1 1 1 1 0
J | 1 1 0 0 1 1 0 1 0 1
In this last grid view you are to assume you have an allergy to some ingredient, you are to pick any ONE of these ingredients, that you declared as an interface, and show which treats are made with that ingredient (1) and which are not (0). In the example, the ingredient "Peanut" was chosen as the allergic ingredient. Position AA shows it's safe to eat (0) but the treat in AB should be avoided (1).
PEANUT ALLERGY
0=NO PEANUTS, 1=CONTAINS PEANUTS
A B C D E F G H I J
----------------------
A | 0 1 1 0 0 0 1 0 0 0
B | 0 0 0 0 0 0 1 0 0 1
C | 0 0 0 0 0 0 0 0 0 1
D | 1 1 0 0 0 1 0 0 0 1
E | 0 0 0 0 0 0 0 0 1 0
F | 1 1 0 0 0 0 1 0 1 1
G | 0 0 0 0 1 1 0 1 0 0
H | 1 0 0 0 0 0 0 0 0 1
I | 0 0 1 0 0 0 0 1 0 0
J | 0 1 0 0 0 1 0 1 0 0
and please help me on create a uml diagram
here are our teacher provide to us sample UML dIagram he expect
BuxiChocolatesSimulatin Our Treats reatesfstarts static Stringn main Stinal ags KettleMade Apples Brittle Creams Clusters PlainCandyApple! PlainCaramelApple ChiliGarlir:PeanutBrittle CashewBrittle GingerCluster mplemenis* irnalernents einterface ecinterface eie face> - Coconut interface> ecinterface Peanuts Caramel Butter Ginge BuxiChocolatesSimulatin Our Treats reatesfstarts static Stringn main Stinal ags KettleMade Apples Brittle Creams Clusters PlainCandyApple! PlainCaramelApple ChiliGarlir:PeanutBrittle CashewBrittle GingerCluster mplemenis* irnalernents einterface ecinterface eie face> - Coconut interface> ecinterface Peanuts Caramel Butter Ginge
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started