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 timeconsuming 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:
TypeFillColorBorderColorBorderThicknessLengthWidthSizePositionDescriptionShapeCodeCreationTime
circleredblack:
squarelbluelyellowel :
trianglegreenblack:
rectanglepurplelorange:
ovalpink red:
circleyellowbluej e
:
squareorangegreen
:
trianglepurplewhite:
rectanglebrownblack
:
ovalcyangrey e:
circlemagentablack
:
squareredblue:
trianglegreenblack
:
rectanglelorangepurplej:
ovalyellowred:
circleblueblack:
squarepinkwhite e:
triangleredgrey:
rectanglegreenblue j:
ovalpurpleblack:
circlelcyanyellow:
squareorangered:
trianglebrownblackjeee:
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 eg triangle, circle, square, rectangle, oval
FillColor the color used to fillthe interior of the shape eg red, green, blue
Border Color: The color of the shape's border or outline eg black, white, yellow
BorderThickness: The thickness of the shape's border, usually measured in pixels eg
Length: Represents one side of rectangular shapes.
Width: Represents the other side of rectangular shapes.
Size: A general dimension for nonrectangular shapes eg 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 eg
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 YYYMMDD 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.
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 addshape 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 modifyshape 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 splayAl that reads the shapes.txt file and displays all shapes
in nice formatted table, showing their attributes
Write a function called displayspecific that prompts the user to enter an attribute eg
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 drawshape that prompts the user to specify which
shapes to draw from the shapes. txt file. The user can
enter a shape type eg 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 generatestatistics 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 eg circle, square color eg red, blue
or size eg 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.txtallowing 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:
Distribution of Colors:
Red:
Yellow:
Blue:
Magenta:
Cyan:
Green:
Black:
Purple:
Average Size:
