Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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