Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Explain in detail and with your own words why classes Rectangle2D, Rectangle2D.Float, and Rectangle2D.Double implement the Template Method design pattern. Why is Rectangle2D an
a) Explain in detail and with your own words why classes Rectangle2D, Rectangle2D.Float, and Rectangle2D.Double implement the Template Method design pattern. Why is Rectangle2D an abstract class ?
b) Consider the SceneEditor.java Explain why the CompoundShape.add method is protected. Explain why CompoundShape.path is private.
01: import java.awt.*; 02: import java.awt.geom.*; 03: import java.awt.event.*; 04: import javax.swing.*; 05 07: A program that allows users to edit a scene composed 08: of items 09: 10: public class SceneEditor 12: public static void main(String[] args) 13: [ JFrame frame new JFrame); 14: 15: 16: 17: 18: 19: 20: 21: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final SceneComponent scene new SceneComponent); JButton houseButton new JButton("House"); houseButton.addActionListener(new ActionListener() public void actionPerformed (ActionEvent event) 24: 25 26: 27: 28: 29: scene.add (new HouseShape (20, 20, 50)); JButton carButton new JButton("Car"); carButton.addActionListener(nevw ActionListener) 31: 32: public void actionPerformed (ActionEvent event) 34: 35: 36: 37: 38: 39: 40: scene.add(new CarShape (20, 20, 50)); JButton removeButton new JButton("Remove"); removeButton.addActionListener (new ActionListener( public void actionPerformed (ActionEvent event) 44: 45: 46: 47: 48: 49: scene.removeSelected) JPanel buttonsnew JPanel); buttons.add(houseButton) buttons.add (carButton); buttons.add (removeButton) 51: 52: 53 54: 55: 56: 57: 58: 59: 60: 61: 62: frame.add (scene, BorderLayout.CENTER); frame.add (buttons, BorderLayout. NORTH); frame.setSize(300, 300 frame.setVisible (true)
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