本文整理匯總了Python中Point.Point.setY方法的典型用法代碼示例。如果您正苦於以下問題:Python Point.setY方法的具體用法?Python Point.setY怎麽用?Python Point.setY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Point.Point
的用法示例。
在下文中一共展示了Point.setY方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import setY [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
示例2: main
# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import setY [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)