@hopebrooke/

OOPS-shape

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class shape():
  def __init__(self, myfillcolour, mycolouroutline, myside):
    self.colourfill = myfillcolour
    self.colouroutline = mycolouroutline
    self.side = myside

  def calculatearea(self):
    return (self.side)*(self.side)

  def setcolour(self, myfillcolour):
    self.colour = myfillcolour

  def printdetails(self):
    print("the shap details are as follows")
    print("the fill cololur is:",self.colourfill)
    print("the outline colour is:",self.colouroutline)
    print("the side length is:",self.side)

class rectangle(shape):
  def __init__(self, myfillcolour, mycolouroutline, myheight,mywidth):
    super().__init__(myfillcolour, mycolouroutline)
    self.height = myheight
    self.width = mywidth

  def calculatearea(self):
    return(self.height*self.width)

class triangle(shape):
  def __init__(self, myfillcolour, mycolouroutline, mybase, myheight):
    super().__init__(myfillcolour, mycolouroutline)
    self.base = mybase
    self.height = myheight
  def calculatearea(self):
    return((self.mybase*self.myheight)/2)
  
class circle(shape):
  def __init__(self, myfillcolour, mycolouroutline, myradius):
    super().__init__(myfillcolour, mycolouroutline)
    self.radius = myradius
  def calculatearea(self):
    return(self.radius*self.radius*3.14)