# Snow man and Snow lady # import turtle import time print('#'*90) print("This program draws a snow man and a snow lady with their own unique set of accesories") print('#'*90) class Shape(object): """General shape class""" def __init__(self, pencolor = "black", pensize = 1): """ create a shape pencolor - color of the pen to use for outlining pensize - size (width) of the pen to use """ self.pencolor = pencolor self.pensize = pensize class Line(Shape): """Line class""" def __init__(self, beg = (0.0, 0.0), end = (50.0, 0.0), pencolor = "black", pensize = 1): """ create a line beg - coordinates of the beginning point end - coordinates of the ending point pencolor - color of the line pensize - size (width) of the line """ Shape.__init__(self,pencolor,pensize) self.beg = beg self.end = end def __str__(self): return "Line(beg:{},end:{})".format(self.beg,self.end) def draw(self, pen): """draw the line using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) pen.up() pen.goto(self.beg) pen.down() pen.goto(self.end) class Circle(Shape): """Circle class""" def __init__(self, beg = (0.0,0.0), radius = 5, pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.beg = beg self.radius = radius """ create a circle beg - coordinates of the beginning point pencolor - color of the line pensize - size (width) of the line radius - radiues of circle to be drawn """ def __str__(self): return "Circle(beg:{},radius:{})".format(self.beg,self.radius) def draw(self,pen): """draw the circle using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.up() turtle.goto(self.beg) turtle.down() turtle.circle(self.radius) class Triangle(Shape): """Triangle class""" def __init__(self, beg = (0.0,0.0), length = 10, pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.beg = beg self.length = length """ create a triangle beg - coordinates of the beginning point pencolor - color of the line pensize - size (width) of the line length - the length of the sides of the triangle to be drawn """ def __str__(self): return "Triangle(beg:{},length:{})".format(self.beg,self.length) def draw(self,pen): """draw the circle using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(1,1,0) turtle.up() turtle.goto(self.beg) turtle.down() turtle.begin_fill() turtle.forward(self.length) turtle.left(120) turtle.forward(self.length) turtle.left(120) turtle.forward(self.length) turtle.left(120) turtle.end_fill() class Square(Shape): """Square class""" def __init__(self, beg = (0.0,0.0), length = 10, pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.beg = beg self.length = length """ create a square beg - coordinates of the beginning point pencolor - color of the line pensize - size (width) of the line length - the length of the sides of the square to be drawn """ def __str__(self): return "Square(beg:{},length:{})".format(self.beg,self.length) def draw(self,pen): """draw the square using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(.689,.132,.203) turtle.begin_fill() turtle.up() turtle.goto(self.beg) turtle.down() turtle.forward(self.length) turtle.left(90) turtle.forward(self.length) turtle.left(90) turtle.forward(self.length) turtle.left(90) turtle.forward(self.length) turtle.left(90) turtle.end_fill() class Rectangle(Shape): """Rectangle class""" def __init__(self, beg = (0.0,0.0), length = 10, width = 2, pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.beg = beg self.length = length self.width = width """ create a rectangle beg - coordinates of the beginning point pencolor - color of the line pensize - size (width) of the line length - the length of two of the sides of the rectangle width - the length of the shorter two sides of the rectangle """ def __str__(self): return "Rectangle(beg:{},length:{},width:{})".format(self.beg,self.length,self.width) def draw(self,pen): """draw the rectangle using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(.689,.132,.203) turtle.begin_fill() turtle.up() turtle.goto(self.beg) turtle.down() turtle.begin_fill() turtle.forward(self.length) turtle.left(90) turtle.forward(self.width) turtle.left(90) turtle.forward(self.length) turtle.left(90) turtle.forward(self.width) turtle.end_fill() class Hat(object): """Hat class""" def __init__(self, a,b,c, length = 10, width = 2, pencolor = "red", pensize = 1): Shape.__init__(self,pencolor,pensize) self.a = a self.b = b self.c = c """ Create a Hat self.a - length of the side of the square to be drawn self.b - length of the two sides of the rectangle to be drawn self.c - width of the shorter sides of the rectangle to be drawn """ def __str__(self): return "Hat(use square side length:{}, and rectangle side length:{} with a side width:{})".format(self.a,self.b,self.c) def draw(self,pen): """draw the hat using the provided pen""" rectangle = Rectangle((-140,90),self.b,self.c,"purple",3) print(rectangle) rectangle.draw(pen) square = Square((-125,145),self.a,"purple",3) print(square) square.draw(pen) class Man_Buttons(object): """Snow Man's Buttons class""" def __init__(self,u,v,w,x,y,z,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) self.u = u self.v = v self.w = w self.x = x self.y = y self.z = z """ Create snow man buttons self.u - is the color percentage for the red variable in making a color for second button and bottom button self.v - is the color percentage for the blue variable in making a color for second button and bottom button self.w - is the color percentage for the green variable in making a color for second button and bottom button self.x - is the color percentage for the red variable in making a color for first button and third button self.y - is the color percentage for the blue variable in making a color for first button and third button self.z - is the color percentage for the green variable in making a color for first button and third button """ def __str__(self): return "Buttons(first button and second button color specs: ({},{},{}),second button and last button color specs:({},{},{}))".format(self.u,self.v,self.w,self.x,self.y,self.z) def draw(self,pen): """draw the snow man buttons using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(self.u,self.v,self.w) turtle.begin_fill() button_1 = Circle((-110,-160),10,"black",3) print(button_1) button_1.draw(pen) turtle.end_fill() turtle.color(self.x,self.y,self.z) turtle.begin_fill() button_2 = Circle((-110,-105),10,"black",3) print(button_2) button_2.draw(pen) turtle.end_fill() turtle.color(self.u,self.v,self.w) turtle.begin_fill() button_3 = Circle((-110,-30),9,"black",3) print(button_3) button_3.draw(pen) turtle.end_fill() turtle.color(self.x,self.y,self.z) turtle.begin_fill() button_4 = Circle((-110,15),9,"black",3) print(button_4) button_4.draw(pen) turtle.end_fill() class Lady_Buttons(object): """Snow lady's Button class""" def __init__(self,u,v,w,x,y,z,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) self.u = u self.v = v self.w = w self.x = x self.y = y self.z = z """ Create snow lady's buttons self.u - is the color percentage for the red variable in making a color for second button and bottom button self.v - is the color percentage for the blue variable in making a color for second button and bottom button self.w - is the color percentage for the green variable in making a color for second button and bottom button self.x - is the color percentage for the red variable in making a color for first button and third button self.y - is the color percentage for the blue variable in making a color for first button and third button self.z - is the color percentage for the green variable in making a color for first button and third button """ def __str__(self): return "Buttons(first button and second button color specs: ({},{},{}),second button and last button color specs:({},{},{}))".format(self.u,self.v,self.w,self.x,self.y,self.z) def draw(self,pen): """draw the snow lady's buttons using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(self.u,self.v,self.w) turtle.begin_fill() button_1 = Circle((100,-170),10,"black",3) print(button_1) button_1.draw(pen) turtle.end_fill() turtle.color(self.x,self.y,self.z) turtle.begin_fill() button_2 = Circle((100,-115),10,"black",3) print(button_2) button_2.draw(pen) turtle.end_fill() turtle.color(self.u,self.v,self.w) turtle.begin_fill() button_3 = Circle((100,-40),9,"black",3) print(button_3) button_3.draw(pen) turtle.end_fill() turtle.color(self.x,self.y,self.z) turtle.begin_fill() button_4 = Circle((100,5),9,"black",3) print(button_4) button_4.draw(pen) turtle.end_fill() class Eyes(object): """Snow person's Eyes class""" def __init__(self,u,v,x,y,z,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) self.u = u self.v = v self.x = x self.y = y self.z = z """ Create eyes class self.u - is the color percentage for the red variable in making a color for the eyes self.v - is the color percentage for the blue variable in making a color for the eyes self.x - is the color percentage for the green variable in making a color for the eyes self.y - is the x coordinate on where to place the left eye self.z - is the x coordinate on where to place the right eye """ def __str__(self): return "Eyes(the color specs of the eyes: ({},{},{}),:The x corrdinate of left eye:{}, the x coordinate of the right eye:{})".format(self.u,self.v,self.x,self.y,self.z) def draw(self,pen): """draw the eyes of the snow person using the provided pen""" turtle.color(self.u,self.v,self.x) turtle.begin_fill() eye1 = Circle((self.y,75),3,"black",3) print(eye1) eye1.draw(pen) turtle.end_fill() turtle.begin_fill() eye2 = Circle((self.z,75),3,"black",3) print(eye2) eye2.draw(pen) turtle.end_fill() class Smile(object): """Snow person's smile class""" def __init__(self,u,v,w,x,y,z,a,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) self.u = u self.v = v self.w = w self.x = x self.y = y self.z = z self.a = a """ Create smile class self.u - is the x coordinate to start the smile of the snow person self.v - is the y coordinate to start the smile of the snow person self.w - is the first x coordinate to draw to and the x coordinate used as a reference to draw to next spot self.x - is the first and second y coordinate to draw to and the y coordinate used as a refernce to draw to next spot self.y - is the second x coordinate to draw to and the second x coordinate used as a reference to drat to next spot self.z - is the third x coordinate to draw to and the final x coordinate drawn to finish the smile self.a - is the third y coordinate to draw to and the final y coordinate drawn to finish the smile """ def __str__(self): return "Smile(the four (x,y) coordinates the smile is drawn to:({},{}),({},{}),({},{}),({},{}))".format(self.u,self.v,self.w,self.x,self.y,self.x,self.z,self.a) def draw(self,pen): """draw the smile of the snow person using the provided pen""" line1 = Line((self.u,self.v),(self.w,self.x),"red", 3) print(line1) line1.draw(pen) line2 = Line((self.w,self.x),(self.y,self.x),"red",3) print(line2) line2.draw(pen) line3 = Line((self.y,self.x),(self.z,self.a),"red",3) print(line3) line3.draw(pen) class Lips(object): """Snow lady's lips class""" def __init__(self, beg = (0.0,0.0), radius = 5, pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.beg = beg self.radius = radius """ create lips class beg - coordinates of the beginning point pencolor - color of the line pensize - size (width) of the line radius - radius of circle a.k.a lips to be drawn """ def __str__(self): return "Lips(beg:{},radius:{})".format(self.beg,self.radius) def draw(self,pen): """draw the Snow lady's lips using the provided pen""" pen.pensize(self.pensize) pen.pencolor(self.pencolor) turtle.color(1,0,0) turtle.up() turtle.goto(self.beg) turtle.down() turtle.begin_fill() turtle.circle(self.radius) turtle.end_fill() turtle.hideturtle() class Hair(object): """Snow lady's hair class""" def __init__(self,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) """ create hair class pencolor - color of the line pensize - size (width) of he line """ def __str__(self): return "Hair uses lines with pen color red to draw the hair on the snow lady" def draw(self,pen): """draw the snow lady's hair using the provided pen""" line1 = Line((75,90),(65,50),"red",3) print(line1) line1.draw(pen) line2 = Line((80,90),(75,70),"red",3) print(line2) line2.draw(pen) line3 = Line((125,90),(135,50),"red",3) print(line3) line3.draw(pen) line3 = Line((120,90),(125,70),"red",3) print(line3) line3.draw(pen) class Snow_person(object): def __init__(self,a,pencolor = "black",pensize = 1): Shape.__init__(self,pencolor,pensize) self.a = a """ create snow person class self.a - the x coordinate to start drawing the snow balls """ def __str__(self): return "Snow_person(snow_person x coordinate to start drawing snowballs:{})".format(self.a) def draw(self,pen): """draw the snow person using the provided pen""" circle = Circle((self.a,-200),70,"black",3) print(circle) circle.draw(pen) circle_2 = Circle((self.a,-60),50,"black",3) print(circle_2) circle_2.draw(pen) circle_3 = Circle((self.a,40),30,"black",3) print(circle_3) circle_3.draw(pen) class Snow_man(object): def __init__(self, snow_person = 'gives him two blue eyes, a red hat, two red arms, a red smile, and four grey buttons', uses = 'circle class, hat class, and the line class',pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.snow = snow_person self.uses = uses def __str__(self): return "Snow_man(snow_man:{},uses:{})".format(self.snow,self.uses) def draw(self,pen): """draw the snow man using the provided pen""" snow_person = Snow_person(-100) print(snow_person) snow_person.draw(pen) hat = Hat(50,80,5) print(hat) hat.draw(pen) buttons = Man_Buttons(.7,.7,.7,.7,.7,.7) print(buttons) buttons.draw(pen) eyes = Eyes(0,0,1,-95,-115) print(eyes) eyes.draw(pen) arm1 = Line((-140,0),(-230,10),"red", 3) print(arm1) arm1.draw(pen) arm2 = Line((-50,0),(30,30),"red",3) print(arm2) arm2.draw(pen) smile = Smile(-115,60,-110,55,-90,-85,60) print(smile) smile.draw(pen) class Snow_lady(object): def __init__(self, snow_person = 'gives her two green eyes, a yellow hat,two yellow buttons,two purple buttons,a red smile, two red arms,red lips, and red hair', uses = 'circle class, triangle class,and line class',pencolor = "black", pensize = 1): Shape.__init__(self,pencolor,pensize) self.snow = snow_person self.uses = uses def __str__(self): return "Snow_person(snow_person:{},uses:{})".format(self.snow,self.uses) def draw(self,pen): """draw the snow lady using the provided pen""" snow_person = Snow_person(100) print(snow_person) snow_person.draw(pen) triangle = Triangle((65,90),70,"black",3) print(triangle) triangle.draw(pen) buttons = Lady_Buttons(1,0,1,1,1,0) print(buttons) buttons.draw(pen) eyes = Eyes(0,1,0,90,110) print(eyes) eyes.draw(pen) arm1 = Line((140,0),(210,-50),"red", 3) print(arm1) arm1.draw(pen) arm1_1 = Line((210,-50),(140,-70),"red",3) print(arm1_1) arm1_1.draw(pen) arm2 = Line((70,0),(-10,10),"red",3) print(arm2) arm2.draw(pen) smile = Smile(115,60,105,55,95,85,60) print(smile) smile.draw(pen) lips = Lips((100,50),6,"black",3) print(lips) lips.draw(pen) hair = Hair() print(hair) hair.draw(pen) def main(): """Uses the complex class functions to make a snow man and snow lady""" pen = turtle.Turtle() turtle.speed(100) snow = Snow_man() print(snow) snow.draw(pen) turtle.up() turtle.goto(0,0) turtle.down() turtle.right(-90) turtle.color(0,0,0) snow1 = Snow_lady() print(snow1) snow1.draw(pen) pen.hideturtle() time.sleep(30) turtle.bye() main()