Credit internet for MathExpressions and now display 12-hour clock instead of 24 hour

This commit is contained in:
Andrew
2021-01-21 17:15:52 -05:00
parent c187403e29
commit 2cbfa70658
3 changed files with 14 additions and 6 deletions
+3
View File
@@ -67,6 +67,9 @@ class AlarmTableCell: UITableViewCell
{
descriptionText.text = "- " + alarm.text
ampm.text = alarm.hour<12 || alarm.hour==24 ? "AM":"PM"
if alarm.hour > 12{
alarm.hour -= 12
}
time.text = alarm.minute<10 ? "\(alarm.hour)" + ":" + "0" + "\(alarm.minute)":"\(alarm.hour)" + ":" + "\(alarm.minute)"
// displays the specific days alarm is activated
+10 -5
View File
@@ -2,10 +2,13 @@
// MathExpressions.swift
// ProjectClock
//
// Class that will generate a simple math expression
// Puzzles to complete for task (math or RPS)
//
//CREDITS: user:2538939 ("Code Different) on Stack Exchange for MathElement enum and MathExpression class on Mar 31 '17
import Foundation
//CREDITS: user:2538939 on Stack Exchange
enum MathElement : CustomStringConvertible {
case Integer(value: Int)
case Percentage(value: Int)
@@ -43,6 +46,7 @@ enum MathOperator : String {
}
}
//CREDITS: user:2538939 on Stack Exchange
class MathExpression : CustomStringConvertible {
var lhs: MathElement
var rhs: MathElement
@@ -120,13 +124,14 @@ let c = MathExpression.random()
class QuadraticProb{
//generates the roots
let root1 = Int.random(in: 1...10)//ax^2
let root2 = Int.random(in: 1...10)//bx
let root1 = Int.random(in: 1...10)
let root2 = Int.random(in: 1...10)
func getProblem() -> String{
let b = root1 + root2
let c = root1 * root2
//a is 1
let b = root1 + root2 //bx
let c = root1 * root2 //x
return "x^2 + \(b) + \(c)"
}
+1 -1
View File
@@ -29,7 +29,7 @@ func jumpAction() {
}
func puzzleAction(puzzleQuestionLabel: UILabel) -> [Int] {
var problem = QuadraticProb()
let problem = QuadraticProb()
let answer = problem.getAnswer()
let problemString = problem.getProblem()