diff --git a/Quizzler-iOS13.xcodeproj/project.pbxproj b/Quizzler-iOS13.xcodeproj/project.pbxproj index 498a95ff..3cead0f1 100644 --- a/Quizzler-iOS13.xcodeproj/project.pbxproj +++ b/Quizzler-iOS13.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 8891902925DDD899002CD202 /* Question.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8891902825DDD899002CD202 /* Question.swift */; }; + 8891903125DED4D7002CD202 /* QuizBrain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8891903025DED4D7002CD202 /* QuizBrain.swift */; }; AD4BDE4A22D878BA005BA4CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */; }; AD4BDE4C22D878BA005BA4CC /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */; }; AD4BDE4E22D878BA005BA4CC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4D22D878BA005BA4CC /* ViewController.swift */; }; @@ -17,6 +19,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 8891902825DDD899002CD202 /* Question.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Question.swift; sourceTree = ""; }; + 8891903025DED4D7002CD202 /* QuizBrain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizBrain.swift; sourceTree = ""; }; AD4BDE4622D878BA005BA4CC /* Quizzler-iOS13.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Quizzler-iOS13.app"; sourceTree = BUILT_PRODUCTS_DIR; }; AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -39,6 +43,31 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 8891902B25DED407002CD202 /* Model */ = { + isa = PBXGroup; + children = ( + 8891902825DDD899002CD202 /* Question.swift */, + 8891903025DED4D7002CD202 /* QuizBrain.swift */, + ); + path = Model; + sourceTree = ""; + }; + 8891902C25DED431002CD202 /* View */ = { + isa = PBXGroup; + children = ( + AD4BDE4F22D878BA005BA4CC /* Main.storyboard */, + ); + path = View; + sourceTree = ""; + }; + 8891902D25DED466002CD202 /* Controller */ = { + isa = PBXGroup; + children = ( + AD4BDE4D22D878BA005BA4CC /* ViewController.swift */, + ); + path = Controller; + sourceTree = ""; + }; AD4BDE3D22D878BA005BA4CC = { isa = PBXGroup; children = ( @@ -61,8 +90,9 @@ children = ( AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */, AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */, - AD4BDE4F22D878BA005BA4CC /* Main.storyboard */, - AD4BDE4D22D878BA005BA4CC /* ViewController.swift */, + 8891902B25DED407002CD202 /* Model */, + 8891902C25DED431002CD202 /* View */, + 8891902D25DED466002CD202 /* Controller */, AD4BDE5222D878BC005BA4CC /* Assets.xcassets */, AD4BDE5422D878BC005BA4CC /* LaunchScreen.storyboard */, AD4BDE5722D878BC005BA4CC /* Info.plist */, @@ -142,7 +172,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8891903125DED4D7002CD202 /* QuizBrain.swift in Sources */, AD4BDE4E22D878BA005BA4CC /* ViewController.swift in Sources */, + 8891902925DDD899002CD202 /* Question.swift in Sources */, AD4BDE4A22D878BA005BA4CC /* AppDelegate.swift in Sources */, AD4BDE4C22D878BA005BA4CC /* SceneDelegate.swift in Sources */, ); diff --git a/Quizzler-iOS13.xcodeproj/project.xcworkspace/xcuserdata/viridianajimenez.xcuserdatad/UserInterfaceState.xcuserstate b/Quizzler-iOS13.xcodeproj/project.xcworkspace/xcuserdata/viridianajimenez.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..d7a19c00 Binary files /dev/null and b/Quizzler-iOS13.xcodeproj/project.xcworkspace/xcuserdata/viridianajimenez.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 00000000..9ce76260 --- /dev/null +++ b/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcschemes/xcschememanagement.plist b/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..73360cf5 --- /dev/null +++ b/Quizzler-iOS13.xcodeproj/xcuserdata/viridianajimenez.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Quizzler-iOS13.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/Quizzler-iOS13/Controller/ViewController.swift b/Quizzler-iOS13/Controller/ViewController.swift new file mode 100644 index 00000000..35a92fc8 --- /dev/null +++ b/Quizzler-iOS13/Controller/ViewController.swift @@ -0,0 +1,115 @@ +// +// ViewController.swift +// Quizzler-iOS13 +// +// Created by Angela Yu on 12/07/2019. +// Copyright © 2019 The App Brewery. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var questionLabel: UILabel! + @IBOutlet weak var progressBar: UIProgressView! + @IBOutlet weak var trueButton: UIButton! + @IBOutlet weak var falseButton: UIButton! + + var questionsCorrect = 0 + let quiz = [ + + Question(q: "A slug's blood is green.", a: "True"), + Question(q: "Approximately one quarter of human bones are in the feet.", a: "True"), + Question(q: "The total surface area of two human lungs is approximately 70 square metres.", a: "True"), + Question(q: "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.", a: "True"), + Question(q: "In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.", a: "False"), + Question(q: "It is illegal to pee in the Ocean in Portugal.", a: "True"), + Question(q: "You can lead a cow down stairs but not up stairs.", a: "False"), + Question(q: "Google was originally called 'Backrub'.", a: "True"), + Question(q: "Buzz Aldrin's mother's maiden name was 'Moon'.", a: "True"), + Question(q: "The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.", a: "False"), + Question(q: "No piece of square dry paper can be folded in half more than 7 times.", a: "False"), + Question(q: "Chocolate affects a dog's heart and nervous system; a few ounces are enough to kill a small dog.", a: "True") + + + + ] + + var questionNumber = 0 + + + + override func viewDidLoad() { + super.viewDidLoad() + progressBar.progress=0 + + + // Do any additional setup after loading the view. + + + updateUI() + } + + @IBAction func answeredButtonPressed(_ sender: UIButton) { + + + let userAnswer = sender.currentTitle!//True or false + let actualAnswer = quiz[questionNumber].answer + + + if userAnswer == actualAnswer { + print("right") + sender.backgroundColor = UIColor.green + + questionsCorrect += 1 + print(questionsCorrect) + progressBar.progress = Float(questionsCorrect)/Float(quiz.count) + } + else{ + print("wrong") + sender.backgroundColor = UIColor.red + } + + questionNumber += 1 + + + Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(updateUI), userInfo: nil, repeats: false) + + + } + + + @objc func updateUI(){ + + + falseButton.backgroundColor = UIColor.clear + + + trueButton.backgroundColor = UIColor.clear + + + + + + + + + + if questionNumber < quiz.count{ + questionLabel.text = quiz[questionNumber].text + + } + else{ + progressBar.progress = 0 + questionNumber = 0 + questionLabel.text = quiz[questionNumber].text + questionsCorrect = 0 + + } + + + + } + +} + diff --git a/Quizzler-iOS13/Model/Question.swift b/Quizzler-iOS13/Model/Question.swift new file mode 100644 index 00000000..da8c7e87 --- /dev/null +++ b/Quizzler-iOS13/Model/Question.swift @@ -0,0 +1,20 @@ +// +// Question.swift +// Quizzler-iOS13 +// +// Created by Viridiana Jimenez on 2/17/21. +// Copyright © 2021 The App Brewery. All rights reserved. +// + +import Foundation + +struct Question { + let text : String + let answer : String + + init(q: String, a: String){ + self.text = q + self.answer = a + } + +} diff --git a/Quizzler-iOS13/Model/QuizBrain.swift b/Quizzler-iOS13/Model/QuizBrain.swift new file mode 100644 index 00000000..9364c1ca --- /dev/null +++ b/Quizzler-iOS13/Model/QuizBrain.swift @@ -0,0 +1,80 @@ +// +// QuizBrain.swift +// Quizzler-iOS13 +// +// Created by Viridiana Jimenez on 2/18/21. +// Copyright © 2021 The App Brewery. All rights reserved. +// + +import Foundation + + +struct QuizBrain { + let quiz = [ + + Question(q: "A slug's blood is green.", a: "True"), + Question(q: "Approximately one quarter of human bones are in the feet.", a: "True"), + Question(q: "The total surface area of two human lungs is approximately 70 square metres.", a: "True"), + Question(q: "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.", a: "True"), + Question(q: "In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.", a: "False"), + Question(q: "It is illegal to pee in the Ocean in Portugal.", a: "True"), + Question(q: "You can lead a cow down stairs but not up stairs.", a: "False"), + Question(q: "Google was originally called 'Backrub'.", a: "True"), + Question(q: "Buzz Aldrin's mother's maiden name was 'Moon'.", a: "True"), + Question(q: "The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.", a: "False"), + Question(q: "No piece of square dry paper can be folded in half more than 7 times.", a: "False"), + Question(q: "Chocolate affects a dog's heart and nervous system; a few ounces are enough to kill a small dog.", a: "True") + + + + ] + + + var questionNumber = 0 + + + func checkAnswer(_ userAnswer: String) -> Bool { + + if userAnswer == quiz[questionNumber].answer{ + //Right + return true + } + else{ + //False + return false + } + } + + + mutating func getQuestionText() -> String { + + return quiz[questionNumber].text + + + + } + + func getQuizL() -> Int { + return quiz.count + } + + func shouldIStop() -> Bool { + if questionNumber < getQuizL(){ + return true + } + else{ + return false + } + + } + + func getProgress() -> Float { + let progress = Float(questionNumber)/Float(quiz.count) + return progress + } + + + + } + + diff --git a/Quizzler-iOS13/Base.lproj/Main.storyboard b/Quizzler-iOS13/View/Base.lproj/Main.storyboard similarity index 83% rename from Quizzler-iOS13/Base.lproj/Main.storyboard rename to Quizzler-iOS13/View/Base.lproj/Main.storyboard index b0f489aa..80538ea9 100644 --- a/Quizzler-iOS13/Base.lproj/Main.storyboard +++ b/Quizzler-iOS13/View/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -30,7 +31,7 @@ - - @@ -65,6 +72,7 @@ + @@ -75,8 +83,13 @@ - + + + + + + diff --git a/Quizzler-iOS13/ViewController.swift b/Quizzler-iOS13/ViewController.swift deleted file mode 100644 index 39ffb5fc..00000000 --- a/Quizzler-iOS13/ViewController.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// ViewController.swift -// Quizzler-iOS13 -// -// Created by Angela Yu on 12/07/2019. -// Copyright © 2019 The App Brewery. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} -