Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminado sin modularidad pero con files #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions Quizzler-iOS13.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -17,6 +19,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
8891902825DDD899002CD202 /* Question.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Question.swift; sourceTree = "<group>"; };
8891903025DED4D7002CD202 /* QuizBrain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizBrain.swift; sourceTree = "<group>"; };
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 = "<group>"; };
AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -39,6 +43,31 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
8891902B25DED407002CD202 /* Model */ = {
isa = PBXGroup;
children = (
8891902825DDD899002CD202 /* Question.swift */,
8891903025DED4D7002CD202 /* QuizBrain.swift */,
);
path = Model;
sourceTree = "<group>";
};
8891902C25DED431002CD202 /* View */ = {
isa = PBXGroup;
children = (
AD4BDE4F22D878BA005BA4CC /* Main.storyboard */,
);
path = View;
sourceTree = "<group>";
};
8891902D25DED466002CD202 /* Controller */ = {
isa = PBXGroup;
children = (
AD4BDE4D22D878BA005BA4CC /* ViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
};
AD4BDE3D22D878BA005BA4CC = {
isa = PBXGroup;
children = (
Expand All @@ -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 */,
Expand Down Expand Up @@ -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 */,
);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "327C90D2-5C72-471F-B9B6-A2C3DC2152AE"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Quizzler-iOS13.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
115 changes: 115 additions & 0 deletions Quizzler-iOS13/Controller/ViewController.swift
Original file line number Diff line number Diff line change
@@ -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

}



}

}

20 changes: 20 additions & 0 deletions Quizzler-iOS13/Model/Question.swift
Original file line number Diff line number Diff line change
@@ -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
}

}
80 changes: 80 additions & 0 deletions Quizzler-iOS13/Model/QuizBrain.swift
Original file line number Diff line number Diff line change
@@ -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
}



}


Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14854.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14806.4"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -30,7 +31,7 @@
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oVw-Hl-IRe">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oVw-Hl-IRe">
<rect key="frame" x="0.0" y="628" width="374" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="ueD-qr-2mT"/>
Expand All @@ -40,8 +41,11 @@
<state key="normal" title="True" backgroundImage="Rectangle">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="answeredButtonPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="DQq-rB-caN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tbn-vQ-GyC">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tbn-vQ-GyC">
<rect key="frame" x="0.0" y="718" width="374" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="fNm-VT-9Ox"/>
Expand All @@ -51,6 +55,9 @@
<state key="normal" title="False" backgroundImage="Rectangle">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="answeredButtonPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="oWV-lT-FJ7"/>
</connections>
</button>
<progressView opaque="NO" contentMode="scaleToFill" progressViewStyle="bar" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="TXm-qh-7Xg">
<rect key="frame" x="0.0" y="808" width="374" height="11"/>
Expand All @@ -65,6 +72,7 @@
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" red="0.14509803921568626" green="0.17254901960784313" blue="0.29019607843137252" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="fal-oS-tEg" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="9eb-B8-Mk2"/>
Expand All @@ -75,8 +83,13 @@
<constraint firstItem="eGL-jB-Wwb" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="gVb-OT-BWs"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="fal-oS-tEg" secondAttribute="bottom" id="wj6-TI-6C2"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="falseButton" destination="tbn-vQ-GyC" id="OwN-fa-lcd"/>
<outlet property="progressBar" destination="TXm-qh-7Xg" id="sqo-Hu-bEH"/>
<outlet property="questionLabel" destination="rSI-li-mhO" id="XIE-6o-qBU"/>
<outlet property="trueButton" destination="oVw-Hl-IRe" id="uO7-C1-zty"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down
20 changes: 0 additions & 20 deletions Quizzler-iOS13/ViewController.swift

This file was deleted.