Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Step One
- INVALID = 0
- class Point( object ):
- '''A point in a graph with x and y coordinates'''
- def __init__( self, uprl, xLoc, yLoc, name = ''):
- '''
- A point is identified by its x and y coordinates,
- It may also have a name, and located in a certain uprl-the quadrant.
- '''
- self.__xLoc = xLoc
- self.__yLoc = yLoc
- self.__name = name
- self.__urpl = uprl
- def getX( self ):
- '''returns the x coordinate'''
- return self.__xLoc
- def getY( self ):
- '''returns the y coordinate'''
- return self.__yLoc
- def getName( self ):
- '''returns name of point'''
- return self.__name
- def getUprl( self ):
- '''returns uprl'''
- return self.__uprl
- def __str__( self ):
- return '(%.5f, %.5f)' %( self.__xLoc, self.__yLoc )
- ## Step Two
- def expand( self, exRate ):
- '''expands values of both x and y'''
- if exRate < 1:
- return INVALID #multiplying points by a negative number or 0 would make the plane smaller, not expand.
- self.__xLoc *= exRate
- self.__yLoc *= exRate
- ## Step Three
- class Quadrant( object ):
- '''Points live in a Quadrant, each Quadrant has a name, they are I, II, III, and IV, each quadrant will have its own points'''
- def __init__( self, I = []. II = [], III = [], IV = []):
- ''''''
- self.I = QuadI
- self.II = QuadII
- self.III = QuadIII
- self.IV = QuadIV
- def createPoints( self ):
- '''An array of points are created and placed into each quadrant'''
- pList = []
- points = []
- pFile = open("points.txt", 'r')
- line = pFile.readline()
- while line != "":
- pList.append(line)
- line = pFile.readline()
- pFile.close()
- for each in pList:
- new = each.split(" ")
- point = str(Point(new[0], new[1], "", ""))
- points.append(point)
- return points
Add Comment
Please, Sign In to add comment