Skip to main content
  1. /classes/
  2. Classes, Spring 2024/
  3. CS 2370 Spring 2024: Course Site/

cs2370 Notes: 21 Flappy Bat

·42 words·1 min·

Classes and Methods

Inheritence

from math import pi

class LawnShape:
    def area(self):
        raise Exception("not implemented")
    
    def cost(self, grassPrice):
        return self.area() * grassPrice

class Circle(LawnShape):
    def __init__(self, radius, cost):
        self.radius = radius
    
    def area(self):
        return pi * pow(self.radius, 2)

Example:

flappy bat v2

Nat Tuck
Author
Nat Tuck