Quadrilaterals
Directions:
- Put 5 quadrilaterals into hierarchical relationship with each other using classes.
- Pick 5 to 8 attributes to talk about for your quadrilaterals. For example, if you pick "number of sides", each of your 5 types of quadrilaterals should be able to print its number of sides.
- When I look at your code, I should only see a definition of a variable in a new class if the variable changed value. For example, number_of_sides should never need to be written after you define your Quadrilateral class.
- At the end of your program, write a print statement for each of your types of quadrilaterals. This means you will print all 5 quadrilaterals. You should print: the name/classification of the quadrilateral and each of your chosen attributes (from step 2).
Organize the following types of quadrilaterals into a hierarchical class structure based on angle measures, congruent sides, etc. Particularly, I want you to use inheritance of class properties when creating children classes.
Types of Quadrilaterals:
|
First, I suggest starting by making sure you know how each of the types relate to the others. A family tree would be helpful in this case.
URL for Quadrilateral Heirarchy: http://www.sawyoo.com/postpic/2012/02/quadrilateral-family-tree_516390.jpg
Next, create a class called quadrilaterals. Be sure to give it an __init__ function with "self" as an argument Properties of quadrilaterals. - Type of Quadrilateral (Classification) (For example, a rhombus is a parallelogram and a kite and a quadrilateral) - 4 sides. - Opposite angles -Congruent? - Opposite sides -Congruent? -Parallel? - Adjacent angles -Congruent? -Supplementary? - Adjacent sides -Congruent? -Perpendicular? - Diagonals -congruent? -bisect each other? -perpendicular? |
If you've not taken Geometry yet: Properties of Quadrilaterals are listed at this website. And at this website. |
You could start like this and then show me how you would only need to change the class variables
class Quadrilateral(object):
#Properties of generic quadrilaterals Classification = "Quadrilateral" #this will change once you get into specific Quadrilaterals. Num_Sides = "4" ...etc. #every class needs one of these. #We won't use it just yet since these classes are all about changing variables via inheritance. def __init__(self): pass #printing the properties of quadrilaterals print("Properties of: \n Quadrilaterals") print (Quadrilateral.Classification) print (Quadrilateral.Num_Sides) ...etc. #I'm sick of writing "Quadrilateral" all the way out. Shortcut! Quad = Quadrilateral print (Quad.Adjacent_Angles) print(Quad.Adjacent_Sides) print(Quad.Diagonals) |