實作按下 . 要怎麼處理
This commit is contained in:
@@ -47,6 +47,15 @@ class Calculator {
|
|||||||
formula.append(formula.popLast()! + text)
|
formula.append(formula.popLast()! + text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ".":
|
||||||
|
if formula.last!.firstIndex(of: ".") != nil {
|
||||||
|
return
|
||||||
|
} else if ["+", "-", "×", "÷"].firstIndex(of: formula.last!) != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
formula.append(formula.popLast()! + text)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print(formula)
|
print(formula)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user