repl.it
@big_deelan/

OOP Tasks

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
42
43
44
45
46
47
#Task 2
class Animal:
  
  def __init__(self, s, n):
    self.size = n
    self.state = s
  
  def feed(self):
    self.size += 1
    if self.size == 5:
      self.state = "FISH"
  
  def getSize(self):
    return self.size

  def getState(self):
    return self.state

#Task 3
myFish = Animal("fish", 1)
print(myFish.state)
print(" is size of ", myFish.size)
while myFish.state != "FISH":
  myFish.feed()
print("It is now a big ")
print(myFish.state)

#Task 4
class Car:

  def __init__(self, r, ma, 0, doi):
    self.reg = r
    self.make = ma
    self.mile = mil
    self.inspect = doi

  def getReg(self):
    return self.reg
    
  def getMake(self):
    return self.ma

  def setMile(self):
    return self.mil

  def setInspect(self):
    return self.doi
Fetching token
?