Commit 23419e7b authored by The Heavy's avatar The Heavy 🚂
Browse files

basics

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
/.idea/

plantmanager.py

0 → 100644
+40 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

import time

class Plant:
    def __init__(self):
        self.height = 0
        self.water = 100
        self.food = 100
        self.pot = 10
        self.timelastgrown = time.time()
        self.colour = 0
        return

    def grow(self):
        if time.time() > self.timelastgrown + 1:
            self.timelastgrown = time.time()
            if self.water > 0:
                self.water -= 10
            else:
                self.colour -= 10
                return
            if self.food > 0:
                self.food -= 1
            else:
                self.colour -= 10
                return
            if self.height < self.pot:
                self.height += 1
        return

if __name__ == "__main__":
    plant = Plant()
    while plant.colour > -100:
        time.sleep(1)
        print(
            "height: {0}; water: {1}; food: {2}; colour: {3};".format(plant.height, plant.water, plant.food,
                                                                      plant.colour))
        plant.grow()
    print("it died")