Question: Problem Description Designing and manipulating shapes can be time - consuming when done manually or with complex software. Many users struggle with advanced design tools

Problem Description
Designing and manipulating shapes can be time-consuming when done manually or with complex
software. Many users struggle with advanced design tools to create and customize shapes. The goal of
this project is to simplify this process by providing an intuitive way for users to draw and modify
basic geometric shapes. The system will allow users to interactively add shapes (such as squares,
circles, and triangles), modify their properties (including color, size, and position), display their
attributes, perform analysis and generate reports about the drawn shapes.
Information about each shape is saved in a text file named shapes.txt, where fields are separated by the
vertical bar character "|". This delimiter ensures the shape details are clearly organized and easy to read,
even when commas are used within the attributes. This structure allows for simple updates, display, and
management of the shapes, keeping the information organized and manageable
Sample of shapes.txt File with Header:
Type|FillColor|BorderColor|BorderThickness|Length|Width|Size|Position|Description|ShapeCode|CreationTime
circle|red|black|2|0|0|50|(100,150)|0|1|2024-10-0110:30
squarelbluelyellow|140140el (200,200)|6|2|2024-10-0111:00
triangle|green|black|3|0|0|30|(150100)|30|3|2024-10-0112:15
rectangle|purplelorange[2|60|40|0|(300,300)|0|4|2024-10-0113:00
oval|pink red|1|80|400|(250,200)|0|5|2024-10-0114:45
circle|yellow|bluej |e
|(50,100)|0|6|2024-10-0115:00
square|orange|green|3|30
0|(100,100)|0|7|2024-10-0209:30
triangle|purple|white2|0|0|25|(200,250)|45|82024-10-0210:15
rectangle|brown|black 1|7050|0|(300,150)|0
6,
2024-10-0211:00
oval|cyan|grey|1|60|30 e|(150,300)|0|10|2024-10-0212:00
circle|magenta|black 2
9
35|(100,200)|0|11|2024-10-0213:30
square|red|blue|1|50|500|(50,50)|0|12|2024-10-0214:15
triangle|green|black 3
40|(250,100)|60|13|2024-10-0215:00
rectanglelorange|purple|2|80|600(400,200)|0j14/2024-10-0216:00
oval|yellow|red|1|90|50|0|(350,150)|0|15|2024-10-0309:00
circle|blue|black|2|0|0|60|(75,125)|0|16|2024-10-0309:45
square|pink|white|1|25|25 e|(300,300)|0|17|2024-10-0310:30
triangle|red|grey|3|0|0|35|(150,150)|45|18|2024-10-0311:00
rectangle|green|blue /2|90|45|0|(100,350)|0j19|2024-10-0312:15
oval|purple|black|1|40|20|0|(350,220)|0|20|2024-10-0313:00
circlelcyan|yellow|2|0|0|40|(120,100)0|21/2024-10-0314:00
square|orange|red|1|60|60|0|(80,80)|0|22|2024-10-0314:45
triangle|brown|black|3je|e|30|(230,13e)|30|23|2024-10-0315:30
In the shapes.txt file, each line represents a record of one shape, and the columns provide detailed
information regarding a shape containing:
Type : the type of shape (e.g., triangle, circle, square, rectangle, oval)
FillColor the color used to fillthe interior of the shape (e.g., red, green, blue).
Border Color: The color of the shape's border or outline (e.g., black, white, yellow).
BorderThickness: The thickness of the shape's border, usually measured in pixels (e-g.,1,2,
3).
Length: Represents one side of rectangular shapes.
Width: Represents the other side of rectangular shapes.
Size: A general dimension for non-rectangular shapes (e.g., radius for circles, side length for
squares, not applicable for rectangles).
Position (x, y) indicates where the shape starts on the turtle graphics screen, using coordinates
in the format (x, y). The x value shows the horizontal position, and the y value shows the
vertical position. The parentheses help to group these two values together as a coordinate pair.
Description: The angle ( in degrees) at which the shape is rotated (e.g.,0,90,180).
ShapeCode: An automatically increasing integer that uniquely identifies each shape. This
ensures that each shape has distinct identifier, which helps in managing and referencing
shapes within the application
CreationTime: A string representing the date and time when the shape was created, formatted
as "Y YYY-MM-DD HH:MM". This allows users to easily track when each shape was added to
the application, which can be useful for documentation or analysis purposes.
1. Requirements
You are required to help this engineer by developing the Bookstore Information System. Your system
should perform the following operations
e
Add a new shape: The function add_shape prompts the user to input the details of a new
shape and adds the data to the shapes.txt file, ensuring that the shape code is auto-
incremented and that the data fields are separated by the |' character.
Modify Shape Properties: Write a function called modify_shape that takes a shape code as a
Parameter. If the shape code is found in the file, the function prompts the user to choose which
properties to change, including fill color, border color, border thickness, size, position, and
rotation. Users can update all or select any combination of these properties. After making the
desired changes, the function saves the updated shape information back to the file.
Delete Shape: write e function delete shape() that takes a shape code as a parameter and
deletes the corresponding shape record from the shapes.txt file.
Display: write a function di splay_Al1() that reads the shapes.txt file and displays all shapes
in nice formatted table, showing their attributes
Write a function called display_specific() that prompts the user to enter an attribute (e.g..
fill color, shape type, etc.) and displays all details for shapes that match the specified attribute
from the shapes.txt file. If no shapes match the given attribute, the function should display
a message indicating that no shapes were found. After displaying the results or the message,
the function should ask the user if they would like to search by another attribute or exit the
function. This process should continue until the user chooses to exit.
Draw Shape: Write a function called draw_shape() that prompts the user to specify which
shapes to draw from the shapes. txt file. The user can
enter a shape type (e.g., circle, square,
triangle, rectangle) or other specific attributes (like color) to filter the shapes they wish to
visualize. The function reads the shape data from the file and uses the Turtle graphics library
to draw only those shapes that match the specified criteria. The function generates also a new
file records. txt containing information about the retrieved shapes, allowing the user to
check the output file later
Generate statistics: Write a function called generate_statistics() that prompts the user to
specify the criteria for generating statistics on the shapes. The user can choose to analyze
shapes based on diferent attributes, such as type (e.g., circle, square), color (e.g., red, blue),
or size (e.g., greater than or less than a specified value).
Once the user provides the criteria, the function calculates relevant statistics, and returns a
dictionary, as follow:
The total number of shapes that meet the specified criteria.
Average size: The mean size of the shapes that match the criteria,
Minimum and maximum sizes: The smallest and largest sizes among the filtered
shapes:
Distribution of colors: A count of how many shapes exist for each specified color. If
the user does not specify color as the criteria
After calculating the desired statistics, the function asks the user ifthey would like to save the
results to a file. If the user confirms, the statistics are written to a separate file named
analysis.txt,allowing for future reference and analysis.
Sample of analysis.txt file for statistics of shapes of type "circle":
Statistics for Shapes of Type: Circle
Total Count: 12
Distribution of Colors:
- Red: 2
- Yellow: 1
- Blue: 2
- Magenta: 1
- Cyan: 1
- Green: 1
- Black: 1
- Purple: 1
Average Size:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!