本文整理汇总了Python中Point.Point.getX方法的典型用法代码示例。如果您正苦于以下问题:Python Point.getX方法的具体用法?Python Point.getX怎么用?Python Point.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.getX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import getX [as 别名]
def main():
# Use this to test the constructor
p1 = Point()
# Use these to test the getters
print ("Default p1 x =", p1.getX())
print ("Default p1 y =", p1.getY())
# Use these to test the setters
p1.setX(1)
p1.setY(2)
print ()
print ("Modified p1 x =", p1.getX())
print ("Modified p1 y =", p1.getY())
# Use this to test the __str__
print ()
print ("Modified Point p1 =", p1)
示例2: __init__
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import getX [as 别名]
class Particle:
def __init__(self, x=0.0, y=0.0, w=1.0):
self.location = Point(x,y)
self.weight = w
def getLocation(self):
return str(self.location.getX())+','+str(self.location.getY())
def getWeight(self):
return self.weight
def setLocation(self,x,y):
self.location.setX(x)
self.location.setY(y)
def setWeight(self, w):
self.weight = w
示例3: Point
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import getX [as 别名]
#!/usr/bin/env python3
# points.py - Point program
from Point import Point
p1 = Point(5, 5) # Point at (5, 5)
p1.down() # move down
p1.right() # move right
print("Point 1 at:", p1.getX(), p1.getY())
p2 = Point(10, 20) # Point at (10, 20)
p2.move(30, 40) # move to (30, 40)
print("Point 2 at:", p2.getX(), p2.getY())
print(Point.numPoints(), "Points")
del p1, p2 # delete Point objects
print(Point.numPoints(), "Points")
#################################################
#
# $ points.py
# Point 1 at: 6 4
# Point 2 at: 30 40
# 2 Points
# 0 Points
#