Starting from:

$30

Assignment #11 Operator Overloading


Assignment #11
Introduction
You will complete one program to give you experience with:
• Lists
• Operator Overloading
• Combining Your Skills
Task 1
Create a class called Polygon. The constructor should take a parameter that sets a private variable
for the number of sides the polygon has. Overload the following operators: +, -, <, , ==, len(), and
str(). Use the number of sides to determine the output of the overloaded operators. Let the user enter
two values used to create two Polygon objects. Then print out all results of the overloaded operators
(using the operator, not calling the dunder method).
Rubric
4 pts: All operators overloaded properly
4 pts: Print results using the overloaded operators
2 pts: Proper output
Task 2
Programming Exercise 10.7.
Rubric
4 pts: Proper use of list to count occurrences of numbers
4 pts: Proper calculations of counts
2 pts: Proper output
Task 3
Create a program that uses Turtle to draw shapes. Show the following menu:
1) Enter Circle
2) Enter Rectangle
3) Sort Shapes
4) Draw Shapes
5) Exit
Circles – User inputs position, radius, and color. The position is the center of the circle
Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner
Colors – Allow red, yellow, blue, and green only
Sort – Sort by: area of the shape; color (give the user the choice of colors); original input order
Draw Shapes – Draw the shapes in the order they are in the list
Guidelines
• Create a class called Circle in its own file
• Create a class called Rectangle in its own file
• In each class create a method called draw() that will draw the shape (as well as anything else
you need)
• Store all Circle and Rectangle objects in a single list
• Use a selection sort to sort the list
• Use a loop to draw all of the shapes
Rubric
5 pts: Software Development Lifecycle Plan (see assn #5 for description)
5 pts: Accurate UML diagrams (Circle and Rectangle)
5 pts: Proper display of all menus and input prompts
10 pts: User can create a circle object with proper content
10 pts: User can create a rectangle object with proper content
20 pts: Sort works for all methods
10 pts: All shapes drawn properly (location, size, color)
10 pts: Single list for all objects
5 pts: List to identify the color
What/How To Turn In (READ THIS)
Submit your files on Canvas.

More products