Skip to content
Permalink
Browse files

Initial Commit

  • Loading branch information...
ConnectionsDigital committed Dec 16, 2018
1 parent 56ec13f commit c0ef0d892443f1d76d444ae86f5a2dcc7ffb6692
@@ -12,6 +12,7 @@
8A92494E21C17F8000E3552A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A92494C21C17F8000E3552A /* Main.storyboard */; };
8A92495021C17F8100E3552A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8A92494F21C17F8100E3552A /* Assets.xcassets */; };
8A92495321C17F8100E3552A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A92495121C17F8100E3552A /* LaunchScreen.storyboard */; };
8AF540E821C1889E0022B072 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8AF540E721C1889E0022B072 /* Assets.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
@@ -22,6 +23,7 @@
8A92494F21C17F8100E3552A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8A92495221C17F8100E3552A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
8A92495421C17F8100E3552A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8AF540E721C1889E0022B072 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../../Elements/Assets.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -54,6 +56,7 @@
8A92494721C17F8000E3552A /* FinalExam1.1 */ = {
isa = PBXGroup;
children = (
8AF540E721C1889E0022B072 /* Assets.xcassets */,
8A92494821C17F8000E3552A /* AppDelegate.swift */,
8A92494A21C17F8000E3552A /* ViewController.swift */,
8A92494C21C17F8000E3552A /* Main.storyboard */,
@@ -124,6 +127,7 @@
files = (
8A92495321C17F8100E3552A /* LaunchScreen.storyboard in Resources */,
8A92495021C17F8100E3552A /* Assets.xcassets in Resources */,
8AF540E821C1889E0022B072 /* Assets.xcassets in Resources */,
8A92494E21C17F8000E3552A /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1,21 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" 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="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="FinalExam1_1" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="jWk-q7-iig">
<rect key="frame" x="20" y="20" width="335" height="206"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Enter Your Grades Below" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5RX-M9-RfK">
<rect key="frame" x="20" y="0.0" width="295" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<color key="textColor" red="0.99607843139999996" green="0.76862745099999996" blue="0.1764705882" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="PMe-Xj-qZj">
<rect key="frame" x="20" y="38" width="295" height="34"/>
<color key="backgroundColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad" keyboardAppearance="alert"/>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vEQ-ZP-kAr">
<rect key="frame" x="20" y="80" width="295" height="34"/>
<color key="backgroundColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad" keyboardAppearance="alert"/>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Fnv-ia-YVX">
<rect key="frame" x="20" y="122" width="295" height="34"/>
<color key="backgroundColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad" keyboardAppearance="alert"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3vn-Fu-TAr">
<rect key="frame" x="20" y="164" width="295" height="42"/>
<color key="backgroundColor" red="0.26051741839999998" green="0.2605243921" blue="0.260520637" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Calculate Grade Average">
<color key="titleColor" red="0.98039215690000003" green="0.4823529412" blue="0.2901960784" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="calculateButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="zos-VJ-FGC"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="3vn-Fu-TAr" secondAttribute="trailing" constant="20" id="08O-aG-J9D"/>
<constraint firstItem="PMe-Xj-qZj" firstAttribute="leading" secondItem="jWk-q7-iig" secondAttribute="leading" constant="20" id="56E-fI-e0Q"/>
<constraint firstItem="5RX-M9-RfK" firstAttribute="leading" secondItem="jWk-q7-iig" secondAttribute="leading" constant="20" id="B1i-uv-VoV"/>
<constraint firstAttribute="trailing" secondItem="PMe-Xj-qZj" secondAttribute="trailing" constant="20" id="EGb-7f-7kp"/>
<constraint firstAttribute="trailing" secondItem="vEQ-ZP-kAr" secondAttribute="trailing" constant="20" id="PJG-Ax-S39"/>
<constraint firstItem="Fnv-ia-YVX" firstAttribute="leading" secondItem="jWk-q7-iig" secondAttribute="leading" constant="20" id="SCI-we-4i0"/>
<constraint firstAttribute="trailing" secondItem="5RX-M9-RfK" secondAttribute="trailing" constant="20" id="bEP-Kt-G4b"/>
<constraint firstAttribute="trailing" secondItem="Fnv-ia-YVX" secondAttribute="trailing" constant="20" id="cqD-H0-Jim"/>
<constraint firstItem="3vn-Fu-TAr" firstAttribute="leading" secondItem="jWk-q7-iig" secondAttribute="leading" constant="20" id="lAG-Nj-PD1"/>
<constraint firstItem="vEQ-ZP-kAr" firstAttribute="leading" secondItem="jWk-q7-iig" secondAttribute="leading" constant="20" id="yoF-KU-b99"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" red="0.12984204290000001" green="0.12984612579999999" blue="0.12984395030000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="jWk-q7-iig" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="20" id="7Vv-vG-Y5V"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="jWk-q7-iig" secondAttribute="trailing" constant="20" id="QMg-Pt-xbA"/>
<constraint firstItem="jWk-q7-iig" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="iAw-dP-9Wr"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="gradeFieldOne" destination="PMe-Xj-qZj" id="Na9-Hb-NIg"/>
<outlet property="gradeFieldThree" destination="Fnv-ia-YVX" id="mc9-jK-Jcf"/>
<outlet property="gradeFieldTwo" destination="vEQ-ZP-kAr" id="Y2X-KP-XLe"/>
<outlet property="resultsLabel" destination="5RX-M9-RfK" id="Ag0-JZ-bBI"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
@@ -9,12 +9,70 @@
import UIKit

class ViewController: UIViewController {


// Setup results label
@IBOutlet weak var resultsLabel: UILabel!

// Setup data entry fields
@IBOutlet weak var gradeFieldOne: UITextField!
@IBOutlet weak var gradeFieldTwo: UITextField!
@IBOutlet weak var gradeFieldThree: UITextField!

// Setup "Calculate Grade Average" button
@IBAction func calculateButton(_ sender: Any) {

// Convert data entry strings to itegers
let grade1 = Int(gradeFieldOne.text!)
let grade2 = Int(gradeFieldTwo.text!)
let grade3 = Int(gradeFieldThree.text!)

// Verify fields contain data
let gradeString1 = (gradeFieldOne.text!)
let gradeString2 = (gradeFieldTwo.text!)
let gradeString3 = (gradeFieldThree.text!)

if(gradeString1.isEmpty) || (gradeString2.isEmpty) || (gradeString3.isEmpty) {
let myAlert = UIAlertController(title: "Alert", message: "All fields are required.", preferredStyle: UIAlertController.Style.alert)

let okAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)

myAlert.addAction(okAction)

self.present(myAlert, animated: true, completion: nil)
return

}

// Declare gradeList array
var gradesList: [Int] = []

// Append grades entered on the acreen to the gradesList array
gradesList.append(grade1!)
gradesList.append(grade2!)
gradesList.append(grade3!)

// Calculate sum of grades
var total = 0
for grade in gradesList {
total += grade
}

// Calculate average
let average = total / gradesList.count

// Display results to device screen
if average >= 70 {
resultsLabel.text = "Your average is \(average). \nYou Passed!"
} else {
resultsLabel.text = "Your average is \(average). \nBetter luck next time."
}
//gradeFieldOne.becomeFirstResponder()
}

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}


}

0 comments on commit c0ef0d8

Please sign in to comment.
You can’t perform that action at this time.