Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Definition: Write a Java application that allows its user to create 2D shapes and manipulate them. Detailed Requirements: First, your program should ask the

Problem Definition: Write a Java application that allows its user to create 2D shapes and manipulate them.

Detailed Requirements:

First, your program should ask the user if he/she wants to load previous drawing work. If the user answers by yes, the previous drawing should be loaded from the text file drawing.txt saved during the last session and displayed; otherwise, the users starts with a blank canvas (drawing area). The program should then display the following menu:

Please, type: 1. To draw a new 2D shape 2. To remove an existing shape 3. To modify an existing shape 4. To quit If the user types 1, your program should ask for the type of the 2D shape to draw (line, rectangle, oval, arc, or polygon). Then it should get from the user all needed information for drawing the shape (color, filled or not, position, etc.) and save them in a list of drawings to be used by paint() when drawing existing 2D shapes.

If the user types 2, your program should ask for the ID of the shape to be removed and remove it. The ID of a shape is the order in which it has been created.

If the user types 3, your program should ask for the ID of the shape to be modified and for the kind of modification to be done (change shape, change color, change position, change fill status, make the shape invisible/visible, etc.) then it executes the user request.

If the user types 4, the program should ask the user if he/she would like to save the final drawing in drawing.txt, execute the user request and stop.

Additional Requirements 1. Create a class called TwoD_Shape that encapsulates 2D shapes to be drawn. This class should include all the properties of the 2D shapes (color, filled or not, type of the shape, etc.) as well as methods necessary for manipulating them.

2. Save all the shapes created by the user in a data structure of type ArrayList. This data structure will be used by main() to save created shapes as well as any modification requested by the user, and by paint() to draw them.

3. Extra 5 marks will be given to the student if the program provides a well-designed and interesting 2D shape (other than oval, line, rectangle, etc) or if he/she uses extra drawing features such as rotations, scaling, including images, etc. Hint: All the calculations should be done in main() or in the adequate TwoD_Shape methods. paint() should be exclusively used for drawing shapes saved in the ArrayList. Call the function repaint() of the created JFrame object, after each performed modification, in order to visualize the effect of that modification.

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

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions