用一個陣列來存放式子

This commit is contained in:
2020-05-06 06:12:37 +08:00
parent aa3277628a
commit 4f81fc3445

View File

@@ -9,14 +9,26 @@
import Foundation
class Calculator {
var process = ""
var formula = ["0"]
var process: String {
get {
var result = ""
formula.forEach { (item) in
result.append(item)
}
return result
}
}
var result = ""
func click(_ text: String) {
if text == "AC" {
process = ""
} else {
process += text
switch text {
case "AC":
// 0
formula = ["0"]
default:
formula.append(text)
}
}
}