Skip to content

Commit

Permalink
Implemented functionality for task 2 and closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vanhoef authored and Peter Vanhoef committed Mar 19, 2017
1 parent ec03202 commit 98941d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Calculator/Calculator/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ class ViewController: UIViewController {
let digit = sender.currentTitle!
if userIsInTheMiddleOfTyping {
let textCurrentlyInDisplay = display.text!
display.text = textCurrentlyInDisplay + digit
if !(digit == "." && textCurrentlyInDisplay.contains(".")) {
display.text = textCurrentlyInDisplay + digit
}
} else {
display.text = digit
if digit == "." {
display.text = "0."
} else {
display.text = digit
}
userIsInTheMiddleOfTyping = true
}
}
Expand Down

0 comments on commit 98941d2

Please sign in to comment.