Credit internet for MathExpressions and now display 12-hour clock instead of 24 hour
This commit is contained in:
@@ -67,6 +67,9 @@ class AlarmTableCell: UITableViewCell
|
|||||||
{
|
{
|
||||||
descriptionText.text = "- " + alarm.text
|
descriptionText.text = "- " + alarm.text
|
||||||
ampm.text = alarm.hour<12 || alarm.hour==24 ? "AM":"PM"
|
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)"
|
time.text = alarm.minute<10 ? "\(alarm.hour)" + ":" + "0" + "\(alarm.minute)":"\(alarm.hour)" + ":" + "\(alarm.minute)"
|
||||||
|
|
||||||
// displays the specific days alarm is activated
|
// displays the specific days alarm is activated
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// MathExpressions.swift
|
// MathExpressions.swift
|
||||||
// ProjectClock
|
// 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
|
import Foundation
|
||||||
|
|
||||||
|
//CREDITS: user:2538939 on Stack Exchange
|
||||||
enum MathElement : CustomStringConvertible {
|
enum MathElement : CustomStringConvertible {
|
||||||
case Integer(value: Int)
|
case Integer(value: Int)
|
||||||
case Percentage(value: Int)
|
case Percentage(value: Int)
|
||||||
@@ -43,6 +46,7 @@ enum MathOperator : String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CREDITS: user:2538939 on Stack Exchange
|
||||||
class MathExpression : CustomStringConvertible {
|
class MathExpression : CustomStringConvertible {
|
||||||
var lhs: MathElement
|
var lhs: MathElement
|
||||||
var rhs: MathElement
|
var rhs: MathElement
|
||||||
@@ -120,13 +124,14 @@ let c = MathExpression.random()
|
|||||||
|
|
||||||
class QuadraticProb{
|
class QuadraticProb{
|
||||||
//generates the roots
|
//generates the roots
|
||||||
let root1 = Int.random(in: 1...10)//ax^2
|
let root1 = Int.random(in: 1...10)
|
||||||
let root2 = Int.random(in: 1...10)//bx
|
let root2 = Int.random(in: 1...10)
|
||||||
|
|
||||||
|
|
||||||
func getProblem() -> String{
|
func getProblem() -> String{
|
||||||
let b = root1 + root2
|
//a is 1
|
||||||
let c = root1 * root2
|
let b = root1 + root2 //bx
|
||||||
|
let c = root1 * root2 //x
|
||||||
|
|
||||||
return "x^2 + \(b) + \(c)"
|
return "x^2 + \(b) + \(c)"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func jumpAction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func puzzleAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
func puzzleAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
||||||
var problem = QuadraticProb()
|
let problem = QuadraticProb()
|
||||||
|
|
||||||
let answer = problem.getAnswer()
|
let answer = problem.getAnswer()
|
||||||
let problemString = problem.getProblem()
|
let problemString = problem.getProblem()
|
||||||
|
|||||||
Reference in New Issue
Block a user