Merge branch 'main' of github.com:hykilpikonna/ProjectClock into main
This commit is contained in:
@@ -51,7 +51,7 @@ class AddAlarmViewController: UIViewController
|
||||
lastActivate: Date())
|
||||
|
||||
// TODO: Set alarm.repeats to correspond with what the user selects
|
||||
|
||||
|
||||
|
||||
// Add the alarm to the list and save the list
|
||||
Alarms.fromLocal().apply { $0.list.append(alarm) }.localSave();
|
||||
|
||||
@@ -137,3 +137,48 @@ class QuadraticProb{
|
||||
return roots
|
||||
}
|
||||
}
|
||||
|
||||
class RPS {
|
||||
|
||||
//@IBOutlet weak var resultsLabel: UILabel!
|
||||
|
||||
enum Choice: String {
|
||||
case rock = "ROCK"
|
||||
case paper = "PAPER"
|
||||
case scissors = "SCISSORS"
|
||||
|
||||
static func randomComputerChoice() -> Choice {
|
||||
let choices: [Choice] = [.rock, .paper, .scissors]
|
||||
return choices[Int.random(in: 0...2)]
|
||||
}
|
||||
}
|
||||
/**
|
||||
@IBAction func rock(_ sender: UIButton) {
|
||||
let computerChoice = Choice.randomComputerChoice()
|
||||
resultsLabel.text = playRPS(you: .rock, computer: computerChoice)
|
||||
}
|
||||
|
||||
@IBAction func paper(_ sender: UIButton) {
|
||||
let computerChoice = Choice.randomComputerChoice()
|
||||
resultsLabel.text = playRPS(you: .paper, computer: computerChoice)
|
||||
}
|
||||
|
||||
@IBAction func scissors(_ sender: UIButton) {
|
||||
let computerChoice = Choice.randomComputerChoice()
|
||||
resultsLabel.text = playRPS(you: .scissors, computer: computerChoice)
|
||||
}
|
||||
*/
|
||||
|
||||
func playRPS(you: Choice, computer: Choice) -> String {
|
||||
if you == computer { return "It's a tie... GO AGAIN!" }
|
||||
else if you == .rock && computer == .scissors { return "You smashed it!" }
|
||||
else if you == .paper && computer == .rock { return "We still don't know how you won..." }
|
||||
else if you == .scissors && computer == .paper { return "You are Dwayne 'The Scissors' Johnson!" }
|
||||
else {
|
||||
let randomNum = Int.random(in: 0...2)
|
||||
if randomNum == 0 { return "Machines win again." }
|
||||
else if randomNum == 1 { return "Go back to robotics!" }
|
||||
else { return "Are you even taking this seriously???" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user