Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How do you acomplish this assignment? Assignment List vs Set with GUI CSIS-1410 Console Output: List: side :14 #0000FF side :18 #FF0000 side : 12
How do you acomplish this assignment?
Assignment List vs Set with GUI CSIS-1410 Console Output: List: side :14 #0000FF side :18 #FF0000 side : 12 #FFFF00 side :18 #FF0000 side: 16 #00FF00 Learning Objectives: Implement equals and hashCode to compare objects of a custom class. User the internet to learn about the interfaces List and Set, and class HashSet Describe the differences between the interfaces List and Set Create, initialize, and display a HashSet Modify an existing GUI application based on specific instructions Demonstrate the benefits of separating functionality and display by using class ColoredSquare both in a console application and in a GUI application Set: side :14 side :12 side: 16 side :18 #0000FF #FFFF00 #00FF00 #FF0000 Description: Download the starter project and import it into Eclipse Import>Existing Projects Into Workspace Implement the classes ColoredSquare and ListVsSetDemo as described below. Uncomment the code in class ListVsSetConsoleApp to test your classes. This test client should not be changed. Once you verified that the classes ColoredSquare and ListVsSetDemo work as expected modify the Gui Application according to the description below Adding a new element: List: side: 14 #0000FF side :18 #FF0000 side : 12 #FFFF00 side :18 #FF0000 side : 16 #00FF00 side :10 #FFC800 Set: side: 14 #0000FF side : 12 #FFFF00 side :10 #FFC800 side : 16 #00FF00 side :18 #FF0000 Ad ColoredSquare: Implement ColoredSquare according to the UML diagram. No class members should be added or removed Important: ColoredSquare should NOT include any print methods Adding a duplicate element List: side: 14 #0000FF side :18 #FF0000 side : 12 #FFFF00 side : 18 #FF0000 side : 16 #00FF00 side :10 #FFC800 side :10 #FFC800 ColoredSquare side int color Color ColoredSquare (s int, c: Color) Hint: import java.awt.Color +area ():int equals ( Object obj): boolean +hashCode(): int toString() String equals 2 colored squares should be considered equal if and only if they have the same size and color. Use Eclipse to auto-implement equals and hashCode toString: The method toString should return a string as shown on the right. e.g. side: 14 #0000FF side : 12 #FFFFee etc. Notice: the toString method of Color displays the rgb values in decimal format. However, in our implementation we use a hexadecimal format like in HTML. Hint 1: To obtain the individual red, green, blue values check out class Color Hint 2: Info on how to format an integer as a 2-digit hexadecimal value Set: side :14 #0000FF side : 12 #FFFF00 side :10 #FFC800 side : 16 #00FF00 side : 18 #FF0000Step 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