Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will program using the Adapter puttem. The serments and steps are given below 1) First, copy the Point class from Assignment

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this assignment, you will program using the Adapter puttem. The serments and steps are given below 1) First, copy the Point class from Assignment I to the new project (Be sure to name the project correctly) 2) Next, create an interface named Shape having just one method tumed display), with no parameters and returning void. A Shape object represents a shape (like a line ar cicle or rectangle) that can be displayed graphically or by listing is sent points on the console. The display mode (graphical or listing is at the discretion of the implementor 3) The interface is implemented by the following class Polygon, which representa polygon. The Point class is from the first assignment. Important convention X Coordinates increase as we move right and coordinates increase as we move down) * The pieces Polymer Set Por public ho Paw Pat S... berpan wo Syrup Singing Singing tor 4) Extend the Shape interface to create an interface sumed FifiedShape to representa shape that can be filled with a celor the user chooses. This interface has the additional method med setColor() with parameters tod. green and locall of type int and can have values between 0 and 255 both end values included) to represent the color of the shape. The implementing class is required to validate the values of the parameters before setting the color 5) Create a class named Robes adapt to implement Filled Shape and use Polygon as the adapte port Our blevold Smutnog USD Save for indende pompom 4) Extend the Shape interface to create an interface named FilledShape to representa shape that can be filled with a color the user chooses. This interface has the additional method named setColor) with 3 parameters red, green, and blue,all of type int and can have values between 0 and 255 both end values included) to represent the color of the shape. The implementing class is required to validate the values of the parameters before setting the color 5) Create a class named Rectangle, which should be an object adapter to implement Filled Shape and use Polygon as the adapter a) Have the necessary field(s) for the Adapter pattern. b) Have the necessary fields for storing the color c) Create a constructor with following signature. The parameters points and point2 are opposite vertices of the rectangle. The constructor compute the other two vertices of the rectangle and uses the adapte (using the constructor and appropriate methods) to store these vertices. (You must devise the logic to generate these Point objects) The implementation should follow the expectations imposed by the adaptce. If the two Point objects do not representa rectangle with non-zero arca (for example, point as the same as point2), the constructor thrones an exception The vertices must be stored in the clockwise direction with point as the first vertex and point2 as the third versek (Remember the convention regarding x and y coordinates in Step 3.) d) Override the display() method, so it works as given in the example. e) Override the toString() method, so it works as given in the example. 1 No other fields or methods are allowed in the class. Implement the FiledShape interface to create a class named Square to representa square. This class should use the Rectangle class as a class adapter. It must follow the requirements given below. a) Create a constructor with following signature. The parameters point and point2 are opposite vertices of the square. The constructor generates the other two vertices of the Square and use the adaptee to store these vertices. (You must devise the logic to generate these Point objects.) public SquarePants If the two Point objects do not representa square with non-zero atea (for example. point is the same as point) or a true square the sides are not equal), the constructor throws an exception. The vertices must be stored in the clockwise direction with point as the first vertex and point2 as the third vertex. (Again, remember the convention ropardimg x and y coordinates in Step 3). b) Override the display() method, so it works as given in the example c) No other fields of methods are allowed in the class. 7) Test your implementation thoroughly. If you have any questions regarding the The program should display the following Polygon vertice 19. * 19. 112, 113, 6) Polygon tostring vertices t), 4119.813.(15.41 Rectile vertices (1, 215,3 13, 14 Tited intr- vertices (1.215.21 5. Alles in Rectangle vertice 15.1. 11. 213.2 Tilled in Ir.) vertices 45 ... 21 21 falled in ir: ,, Rectangle vertice 11. 11. 29. 21 3.31 Tited in Ir. vertices (1, 31 (1, 2) , 25. Billed in ir 100. 200, 156) Rectangle vertices 1.275 .. (1.21 filled in it..... vertices (5,21 5. B1, B2) Filled in iro, the exception for rectangle Square vertices (4, 5), (3, 4, filled in ... - vertices (4.5) (8.51 68, 9) (4.91 Filled in ir- the exception for sure The above example does not necessarily exercise the functionality thoroughly, including the situations that raise exceptions when the parameters to the Rectangle/Square constructors are inappropriate, color change, etc. Submission Submit the Eclipse Java project Follow the following steps to upload your code to D2L: Create a java project and call it your tastanelernt) (eg mine will be called Dathanssinena). If you wish, you can add a qualifier to add the course name to have the form your taste. Create add the sava files to implement the classes as described above Archive the project into one zip file using Eclipse using the following steps In Eclipse Project Explorer, right click on the project folder of the project and click on Export Choose General then Archive File and click Next Use the Browse key to choose a folder to store the archive file on your hard drive and give the file the same name as your project ( Dathanaaginent.zip), then click Save, then click Finish. Upload the zip file you created to the D2L folder called asignant The most recent submission will be graded, unless you indicate so in the submission page Grading The project must be named as specified above. If you don't follow this naming convention or don't submit an Eclipse project, there will be a penalty of 10% Interfaces created as required 4 Rectangle class implemented as required 16 Square class implemented as required 10 Correctness 10 Coding Conventions and Documentation 10 If the two Point objects do not representare with non-zero area (for example, point is the same as point of a true pare the sides are not equal, the constructor thus an exception. The vertices must be stored in the clockwise direction with point as the fine vents and point2 as the third vertex (Again. remember the convention online and coordinates in Stop 3) b) Override she display methed, so it works as given in the example. c) No other fields of methods are allowed in the class 7) Test your implementation throughly. If you have any questions regarding the steps directions, you must contact me in a timely manner ) Submit the Java Eclipse project Example When the following code is executed DO Paas Rs Poros PoE gonado Sy Rectangle dagene om Sy age 2.de Sy texte Net 100 100 300 Calor 100. delakor, 100 100-10 2010 Rectangle delay Eyni . cachon bewon. y ht The program should display the following Polygon Vertica..., Polyota vertices 0.9.83.25.99 Rectangle Vertices 11. 21. 215.8.11 ... >> wertes (1, 215, 215, B1, TALE vertices 5.8) 1.8 (1.10.2) ...... Rectangle Traces : 13.215.2.5 Rectangle vertices 11. BI 1.21 3.215 ... w 1.8 (1.21 5.213.10.2015 Rectangle Wortes, 21, 11.2 Tier, vertices 13. 2) 15. Bi (1. 1. 2 Tier... - The Formente Square wrices 1458, S. 16. tate, vertices ... let, throw except for In this assignment, you will program using the Adapter puttem. The serments and steps are given below 1) First, copy the Point class from Assignment I to the new project (Be sure to name the project correctly) 2) Next, create an interface named Shape having just one method tumed display), with no parameters and returning void. A Shape object represents a shape (like a line ar cicle or rectangle) that can be displayed graphically or by listing is sent points on the console. The display mode (graphical or listing is at the discretion of the implementor 3) The interface is implemented by the following class Polygon, which representa polygon. The Point class is from the first assignment. Important convention X Coordinates increase as we move right and coordinates increase as we move down) * The pieces Polymer Set Por public ho Paw Pat S... berpan wo Syrup Singing Singing tor 4) Extend the Shape interface to create an interface sumed FifiedShape to representa shape that can be filled with a celor the user chooses. This interface has the additional method med setColor() with parameters tod. green and locall of type int and can have values between 0 and 255 both end values included) to represent the color of the shape. The implementing class is required to validate the values of the parameters before setting the color 5) Create a class named Robes adapt to implement Filled Shape and use Polygon as the adapte port Our blevold Smutnog USD Save for indende pompom 4) Extend the Shape interface to create an interface named FilledShape to representa shape that can be filled with a color the user chooses. This interface has the additional method named setColor) with 3 parameters red, green, and blue,all of type int and can have values between 0 and 255 both end values included) to represent the color of the shape. The implementing class is required to validate the values of the parameters before setting the color 5) Create a class named Rectangle, which should be an object adapter to implement Filled Shape and use Polygon as the adapter a) Have the necessary field(s) for the Adapter pattern. b) Have the necessary fields for storing the color c) Create a constructor with following signature. The parameters points and point2 are opposite vertices of the rectangle. The constructor compute the other two vertices of the rectangle and uses the adapte (using the constructor and appropriate methods) to store these vertices. (You must devise the logic to generate these Point objects) The implementation should follow the expectations imposed by the adaptce. If the two Point objects do not representa rectangle with non-zero arca (for example, point as the same as point2), the constructor thrones an exception The vertices must be stored in the clockwise direction with point as the first vertex and point2 as the third versek (Remember the convention regarding x and y coordinates in Step 3.) d) Override the display() method, so it works as given in the example. e) Override the toString() method, so it works as given in the example. 1 No other fields or methods are allowed in the class. Implement the FiledShape interface to create a class named Square to representa square. This class should use the Rectangle class as a class adapter. It must follow the requirements given below. a) Create a constructor with following signature. The parameters point and point2 are opposite vertices of the square. The constructor generates the other two vertices of the Square and use the adaptee to store these vertices. (You must devise the logic to generate these Point objects.) public SquarePants If the two Point objects do not representa square with non-zero atea (for example. point is the same as point) or a true square the sides are not equal), the constructor throws an exception. The vertices must be stored in the clockwise direction with point as the first vertex and point2 as the third vertex. (Again, remember the convention ropardimg x and y coordinates in Step 3). b) Override the display() method, so it works as given in the example c) No other fields of methods are allowed in the class. 7) Test your implementation thoroughly. If you have any questions regarding the The program should display the following Polygon vertice 19. * 19. 112, 113, 6) Polygon tostring vertices t), 4119.813.(15.41 Rectile vertices (1, 215,3 13, 14 Tited intr- vertices (1.215.21 5. Alles in Rectangle vertice 15.1. 11. 213.2 Tilled in Ir.) vertices 45 ... 21 21 falled in ir: ,, Rectangle vertice 11. 11. 29. 21 3.31 Tited in Ir. vertices (1, 31 (1, 2) , 25. Billed in ir 100. 200, 156) Rectangle vertices 1.275 .. (1.21 filled in it..... vertices (5,21 5. B1, B2) Filled in iro, the exception for rectangle Square vertices (4, 5), (3, 4, filled in ... - vertices (4.5) (8.51 68, 9) (4.91 Filled in ir- the exception for sure The above example does not necessarily exercise the functionality thoroughly, including the situations that raise exceptions when the parameters to the Rectangle/Square constructors are inappropriate, color change, etc. Submission Submit the Eclipse Java project Follow the following steps to upload your code to D2L: Create a java project and call it your tastanelernt) (eg mine will be called Dathanssinena). If you wish, you can add a qualifier to add the course name to have the form your taste. Create add the sava files to implement the classes as described above Archive the project into one zip file using Eclipse using the following steps In Eclipse Project Explorer, right click on the project folder of the project and click on Export Choose General then Archive File and click Next Use the Browse key to choose a folder to store the archive file on your hard drive and give the file the same name as your project ( Dathanaaginent.zip), then click Save, then click Finish. Upload the zip file you created to the D2L folder called asignant The most recent submission will be graded, unless you indicate so in the submission page Grading The project must be named as specified above. If you don't follow this naming convention or don't submit an Eclipse project, there will be a penalty of 10% Interfaces created as required 4 Rectangle class implemented as required 16 Square class implemented as required 10 Correctness 10 Coding Conventions and Documentation 10 If the two Point objects do not representare with non-zero area (for example, point is the same as point of a true pare the sides are not equal, the constructor thus an exception. The vertices must be stored in the clockwise direction with point as the fine vents and point2 as the third vertex (Again. remember the convention online and coordinates in Stop 3) b) Override she display methed, so it works as given in the example. c) No other fields of methods are allowed in the class 7) Test your implementation throughly. If you have any questions regarding the steps directions, you must contact me in a timely manner ) Submit the Java Eclipse project Example When the following code is executed DO Paas Rs Poros PoE gonado Sy Rectangle dagene om Sy age 2.de Sy texte Net 100 100 300 Calor 100. delakor, 100 100-10 2010 Rectangle delay Eyni . cachon bewon. y ht The program should display the following Polygon Vertica..., Polyota vertices 0.9.83.25.99 Rectangle Vertices 11. 21. 215.8.11 ... >> wertes (1, 215, 215, B1, TALE vertices 5.8) 1.8 (1.10.2) ...... Rectangle Traces : 13.215.2.5 Rectangle vertices 11. BI 1.21 3.215 ... w 1.8 (1.21 5.213.10.2015 Rectangle Wortes, 21, 11.2 Tier, vertices 13. 2) 15. Bi (1. 1. 2 Tier... - The Formente Square wrices 1458, S. 16. tate, vertices ... let, throw except for

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

When is the appropriate time to write a business plan?

Answered: 1 week ago

Question

LO2 Explain the major laws governing employee compensation.

Answered: 1 week ago