Guest User

Untitled

a guest
Apr 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. ## Step One
  2. INVALID = 0
  3. class Point( object ):
  4. '''A point in a graph with x and y coordinates'''
  5. def __init__( self, uprl, xLoc, yLoc, name = ''):
  6. '''
  7. A point is identified by its x and y coordinates,
  8. It may also have a name, and located in a certain uprl-the quadrant.
  9. '''
  10. self.__xLoc = xLoc
  11. self.__yLoc = yLoc
  12. self.__name = name
  13. self.__urpl = uprl
  14. def getX( self ):
  15. '''returns the x coordinate'''
  16. return self.__xLoc
  17. def getY( self ):
  18. '''returns the y coordinate'''
  19. return self.__yLoc
  20. def getName( self ):
  21. '''returns name of point'''
  22. return self.__name
  23. def getUprl( self ):
  24. '''returns uprl'''
  25. return self.__uprl
  26. def __str__( self ):
  27. return '(%.5f, %.5f)' %( self.__xLoc, self.__yLoc )
  28. ## Step Two
  29. def expand( self, exRate ):
  30. '''expands values of both x and y'''
  31. if exRate < 1:
  32. return INVALID #multiplying points by a negative number or 0 would make the plane smaller, not expand.
  33. self.__xLoc *= exRate
  34. self.__yLoc *= exRate
  35.  
  36. ## Step Three
  37. class Quadrant( object ):
  38. '''Points live in a Quadrant, each Quadrant has a name, they are I, II, III, and IV, each quadrant will have its own points'''
  39. def __init__( self, I = []. II = [], III = [], IV = []):
  40. ''''''
  41. self.I = QuadI
  42. self.II = QuadII
  43. self.III = QuadIII
  44. self.IV = QuadIV
  45. def createPoints( self ):
  46. '''An array of points are created and placed into each quadrant'''
  47. pList = []
  48. points = []
  49. pFile = open("points.txt", 'r')
  50. line = pFile.readline()
  51. while line != "":
  52. pList.append(line)
  53. line = pFile.readline()
  54. pFile.close()
  55. for each in pList:
  56. new = each.split(" ")
  57. point = str(Point(new[0], new[1], "", ""))
  58. points.append(point)
  59. return points
Add Comment
Please, Sign In to add comment