Skip to content
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 */
6E56B9AE28D3F963005C4BC2 /* QuizBrain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E56B9AD28D3F963005C4BC2 /* QuizBrain.swift */; };
6E6D3A7728D274D100B7D080 /* Pregunta.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6D3A7628D274D100B7D080 /* Pregunta.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 */
6E56B9AD28D3F963005C4BC2 /* QuizBrain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizBrain.swift; sourceTree = "<group>"; };
6E6D3A7628D274D100B7D080 /* Pregunta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pregunta.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 */
6E56B9AA28D3F84D005C4BC2 /* Model */ = {
isa = PBXGroup;
children = (
6E6D3A7628D274D100B7D080 /* Pregunta.swift */,
6E56B9AD28D3F963005C4BC2 /* QuizBrain.swift */,
);
path = Model;
sourceTree = "<group>";
};
6E56B9AB28D3F85D005C4BC2 /* View */ = {
isa = PBXGroup;
children = (
AD4BDE4F22D878BA005BA4CC /* Main.storyboard */,
);
path = View;
sourceTree = "<group>";
};
6E56B9AC28D3F864005C4BC2 /* 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 */,
6E56B9AA28D3F84D005C4BC2 /* Model */,
6E56B9AB28D3F85D005C4BC2 /* View */,
6E56B9AC28D3F864005C4BC2 /* Controller */,
AD4BDE5222D878BC005BA4CC /* Assets.xcassets */,
AD4BDE5422D878BC005BA4CC /* LaunchScreen.storyboard */,
AD4BDE5722D878BC005BA4CC /* Info.plist */,
Expand Down Expand Up @@ -142,9 +172,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6E56B9AE28D3F963005C4BC2 /* QuizBrain.swift in Sources */,
AD4BDE4E22D878BA005BA4CC /* ViewController.swift in Sources */,
AD4BDE4A22D878BA005BA4CC /* AppDelegate.swift in Sources */,
AD4BDE4C22D878BA005BA4CC /* SceneDelegate.swift in Sources */,
6E6D3A7728D274D100B7D080 /* Pregunta.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
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>
60 changes: 60 additions & 0 deletions Quizzler-iOS13/Controller/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// 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 labelPuntaje: UILabel!
@IBOutlet weak var labelPregunta: UILabel!
@IBOutlet weak var barraProgreso: UIProgressView!
@IBOutlet weak var botonTrue: UIButton!
@IBOutlet weak var botonFalse: UIButton!
var quizBrain = QuizBrain()

var timer = Timer()

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
cambiarPregunta()
}


@IBAction func botonRespuestaApretado(_ sender: UIButton) {
let respuesta = sender.currentTitle!
let respuestaCorrecta = quizBrain.verificarRespuesta(respuesta: respuesta)
if respuestaCorrecta {
quizBrain.aumentarPuntaje()
sender.backgroundColor = UIColor.green
} else {
sender.backgroundColor = UIColor.red
}
quizBrain.siguientePregunta()

timer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false, block: { (time) in
self.cambiarPregunta()
})




}


func cambiarPregunta(){

labelPregunta.text = quizBrain.getTextoPregunta()
barraProgreso.progress = quizBrain.getProgreso()
labelPuntaje.text = "Puntaje: \(quizBrain.getPuntaje())"
botonTrue.backgroundColor = UIColor.clear
botonFalse.backgroundColor = UIColor.clear

}
}

15 changes: 15 additions & 0 deletions Quizzler-iOS13/Model/Pregunta.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Pregunta.swift
// Quizzler-iOS13
//
// Created by Pablo Pizarro on 14/09/2022.
// Copyright © 2022 The App Brewery. All rights reserved.
//

import Foundation

struct Pregunta {
let q : String
let a : [String]

}
70 changes: 70 additions & 0 deletions Quizzler-iOS13/Model/QuizBrain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// QuizBrain.swift
// Quizzler-iOS13
//
// Created by Pablo Pizarro on 15/09/2022.
// Copyright © 2022 The App Brewery. All rights reserved.
//

import Foundation


struct QuizBrain{
let preguntas = [ Pregunta(q: "A slug's blood is green.", a: "True"),
Pregunta(q: "Approximately one quarter of human bones are in the feet.", a: "True"),
Pregunta(q: "The total surface area of two human lungs is approximately 70 square metres.", a: "True"),
Pregunta(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"),
Pregunta(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"),
Pregunta(q: "It is illegal to pee in the Ocean in Portugal.", a: "True"),
Pregunta(q: "You can lead a cow down stairs but not up stairs.", a: "False"),
Pregunta(q: "Google was originally called 'Backrub'.", a: "True"),
Pregunta(q: "Buzz Aldrin's mother's maiden name was 'Moon'.", a: "True"),
Pregunta(q: "The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.", a: "False"),
Pregunta(q: "No piece of square dry paper can be folded in half more than 7 times.", a: "False"),
Pregunta(q: "Chocolate affects a dog's heart and nervous system; a few ounces are enough to kill a small dog.", a: "True")

]




var preguntaActual = 0
var puntaje = 0


func verificarRespuesta(respuesta: String) -> Bool{
if respuesta == preguntas[preguntaActual].a{
return true
} else {
return false

}
}


func getTextoPregunta() -> String{
return preguntas[preguntaActual].q
}

func getProgreso() -> Float{
return Float(preguntaActual) / Float(preguntas.count - 1)
}

//mutating para poder cambiar un variable del struct
mutating func siguientePregunta(){
if preguntaActual < preguntas.count - 1{
preguntaActual += 1
} else {
puntaje = 0
preguntaActual = 0
}
}

mutating func aumentarPuntaje(){
self.puntaje += 1
}

func getPuntaje() -> Int{
return self.puntaje
}
}
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="20037" 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="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -24,13 +25,19 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="fal-oS-tEg">
<rect key="frame" x="20" y="44" width="374" height="818"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ykH-7o-fFp">
<rect key="frame" x="0.0" y="0.0" width="374" height="71.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalCompressionResistancePriority="1000" text="Question Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rSI-li-mhO">
<rect key="frame" x="0.0" y="0.0" width="374" height="618"/>
<rect key="frame" x="0.0" y="81.5" width="374" height="536.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="30"/>
<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 +47,11 @@
<state key="normal" title="True" backgroundImage="Rectangle">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="botonRespuestaApretado:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Zg6-Eo-ERd"/>
</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 +61,9 @@
<state key="normal" title="False" backgroundImage="Rectangle">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="botonRespuestaApretado:" destination="BYZ-38-t0r" eventType="touchUpInside" id="W9I-eU-uPU"/>
</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 +78,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 +89,14 @@
<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="barraProgreso" destination="TXm-qh-7Xg" id="TWz-Vg-EbH"/>
<outlet property="botonFalse" destination="tbn-vQ-GyC" id="pNy-rs-vaG"/>
<outlet property="botonTrue" destination="oVw-Hl-IRe" id="3x5-zg-IMk"/>
<outlet property="labelPregunta" destination="rSI-li-mhO" id="9JK-ph-VDU"/>
<outlet property="labelPuntaje" destination="ykH-7o-fFp" id="pIT-Sa-Xjb"/>
</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.