# David Mailhot, CSE143 python lecture #2 (objects) # A Hole object is used to represent the point of a dug hole # with the TreasureManager class. It acts like the familiar # Point, but it instead includes a radius, as well as a draw method from math import * class Hole: def __init__(self, x, y, radius): self.x = x self.y = y self.radius = radius def draw(self, panel): top_x = self.x - self.radius top_y = self.y - self.radius panel.canvas.create_oval(top_x, top_y, top_x + self.radius*2, top_y + self.radius*2, outline="white", fill="white") def distance(self, x, y): dx = self.x - x dy = self.y - y return sqrt(dx * dx + dy * dy) def __str__(self): return "(" + str(self.x) + ", " + str(self.y) + ")"