Question: Java , URGENT Composite Pattern Week 12 1 Context Composite pattern is a partitioning design pattern and describes a group of objects that is treated

 Java , URGENT Composite Pattern Week 12 1 Context Composite patternis a partitioning design pattern and describes a group of objects that

Java , URGENT

Composite Pattern Week 12 1 Context Composite pattern is a partitioning design pattern and describes a group of objects that is treated the same way as a single instance of the same type of object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. It allows you to have a tree structure and ask each node in the tree structure to perform a task. 2 Problem description Consider the following computer architecture: Keyboard CPU Computer Memory Monitor Graph card GPU Memory In the graph, CPU, GPU, memory, monitor and keyboard are atomic components, while graph card and computer are composites. Every atomic component has a price associated with it. The price of a composite part is the sum of all its components. For example, the price of the computer is the sum of the price of the monitor, CPU, keyboard, memory and the graph card, and the price of the graph card is the sum of the price of the GPU and the memory. 3 Measure of success run-single: Device name : GPU Price : 10 Device name : Memory Price : 15 Composite name : GraphCard Total price : 25 Device name : CPU Price : 14 Device name : Monitor Price : 30 Device name : Keyboard Price : 11 Device name : Memory Price : 15 Composite name : Computer Total price : 95 Total price : 95 BUILD SUCCESSFUL (total time: 6 seconds)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!