Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- width = 15
- length = 10;
- class point:
- def __init__ (self, xin, yin, dispin = '!'):
- self.xpos, self.ypos = xin, yin
- self.disp = dispin
- def set_pos (self, x, y):
- self.xpos, self.ypos = x, y
- class Data:
- def __init__ (self):
- self.points = []
- def search_coord (self, x, y):
- for check in self.points:
- if check.xpos == x and check.ypos == y:
- return check.disp
- return ' '
- def display (self):
- for yd in range (length):
- for xd in range (width):
- occ = self.search_coord (xd, yd)
- print ("{:>3}".format (occ), end = '')
- print ('\n')
- def add_point (self, x, y, d = '?'):
- tpoint = point (x, y, d)
- self.points.append (tpoint)
- data = Data ()
- data.add_point (0, 0, '$')
- data.add_point (5, 5, '+')
- data.add_point (9, 9, '()')
- data.display ()
Advertisement
Add Comment
Please, Sign In to add comment