本文整理汇总了Python中Model.Model.isNumber方法的典型用法代码示例。如果您正苦于以下问题:Python Model.isNumber方法的具体用法?Python Model.isNumber怎么用?Python Model.isNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.isNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import isNumber [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