本文整理匯總了Python中View.View.printOp方法的典型用法代碼示例。如果您正苦於以下問題:Python View.printOp方法的具體用法?Python View.printOp怎麽用?Python View.printOp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類View.View
的用法示例。
在下文中一共展示了View.printOp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from View import View [as 別名]
# 或者: from View.View import printOp [as 別名]
class Controller:
def __init__(self):
self.model = Model()
self.view = View()
self.firstTime = True
self.result = 0.0
self.a = 0.0
self.b = 0.0
self.usePrev = 0
def run(self):
while True:
self.view.printMenu()
selection = self.view.inputSelection()
if selection <= 0:
continue
elif selection == 5:
self.view.terminate()
return
elif not self.firstTime:
if self.model.isNumber(self.result):
self.usePrev = self.view.usePrevious(self.result)
else:
self.usePrev = 0
else:
self.firstTime = False
if self.usePrev == 0:
# Enter both operands
self.a = self.view.oneOp(1)
self.b = self.view.oneOp(2)
elif self.usePrev == 1:
# Enter second operand
self.a = self.result
self.view.printOp(1, self.a)
self.b = self.view.oneOp(2)
elif self.usePrev == 2:
# Enter first operand
self.a = self.view.oneOp(1)
self.b = self.result
self.view.printOp(2, self.b)
else:
# ERROR: Should never reach this block
self.view.printInvalidArg()
continue
self.view.printCalc(selection, self.a, self.b)
self.result = self.model.calculate(selection, self.a, self.b)
self.view.printResult(self.result)
if self.view.anotherOp():
continue
else:
return