Skip to content
Open
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f8189d4
Create MiguelsProject
Marquez5301 May 6, 2020
1f63b64
Delete MiguelsProject
Marquez5301 May 6, 2020
6e65733
Update Contents.swift
Marquez5301 May 6, 2020
5e459ce
First revision, I added a FlightStatus enum in line 20
Marquez5301 May 7, 2020
c528326
Second revision, I added an Airport struct at line 29
Marquez5301 May 7, 2020
18e6f77
Third revision, I added a DepartureBoard class at line 44
Marquez5301 May 7, 2020
5efd7dc
Fourth revision, I added a a Flight struct aat line 60
Marquez5301 May 7, 2020
f48f00a
Fifth revision, I added a reference of DepartureBoard called myDeparture
Marquez5301 May 7, 2020
d27ec6d
Sixth revision, I added three instances to my Flight array and I appe…
Marquez5301 May 7, 2020
fceb172
Seventh revision, I added a For Loop to my ENUM
Marquez5301 May 7, 2020
a8d9733
Eighth revision, I re-wrote a For Loop with Case iteration on line 102
Marquez5301 May 7, 2020
b6d6f85
Ninth revision, I fixed myDeparture instance on line 84
Marquez5301 May 7, 2020
ffa3ab6
Tenth revision, I renamed OtherFlightStatus to FlightStatus2 on line 102
Marquez5301 May 7, 2020
a15176a
Eleventh revision, fixed my code on line 103
Marquez5301 May 8, 2020
557dedc
Twelfth revision, added a Date command at lines, 64, 71, 86, 87, 88
Marquez5301 May 8, 2020
0421a3e
Thirteenth revision, added NIL value at line 87
Marquez5301 May 8, 2020
c20827e
Fourteenth revision, I created a printDeparture2 func
Marquez5301 May 8, 2020
fcf7051
Fifteenth revision, I created an alertPassengers func on lines 147 -…
Marquez5301 May 8, 2020
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
78 changes: 75 additions & 3 deletions AirportDepartures.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit

// New changes

//: ## 1. Create custom types to represent an Airport Departures display
//: ![Airport Departures](matthew-smith-5934-unsplash.jpg)
Expand All @@ -16,9 +17,60 @@ import UIKit
//: e. Use a `String?` for the Terminal, since it may not be set yet (i.e.: waiting to arrive on time)
//:
//: f. Use a class to represent a `DepartureBoard` with a list of departure flights, and the current airport



enum FlighStatus: String {
case route = "On-Time"
case scheduled = "Scheduled"
case canceled = "Cancelled"
case delayed = "Delayed"
case boarding = "Boarding"
}


struct Airport {
let planes: Int
let hotel: String
let transport: String
let carRental: String

init(planes: Int, hotel: String, transport: String, carRental: String) {
self.planes = planes
self.hotel = hotel
self.transport = transport
self.carRental = carRental
}
}

class DepartureBoard {
let destination: String
let airline: String
let departureTime: String
let terminal: Int
let status: FlighStatus
var flights: [Flight]

init(destination: String, airline: String, departureTime: String, terminal: Int, status: FlighStatus, flights: [Flight]) {
self.destination = destination
self.airline = airline
self.departureTime = departureTime
self.terminal = terminal
self.status = status
self.flights = []
}
}

struct Flight {
let pilots: Int
let attendants: Int
let passengers: Int
let ticketClass: String

init(pilots: Int, attendants: Int, passengers: Int, ticketClass: String) {
self.pilots = pilots
self.attendants = attendants
self.passengers = passengers
self.ticketClass = ticketClass
}
}
//: ## 2. Create 3 flights and add them to a departure board
//: a. For the departure time, use `Date()` for the current time
//:
Expand All @@ -29,8 +81,15 @@ import UIKit
//: d. Make one of the flights have a `nil` terminal because it has not been decided yet.
//:
//: e. Stretch: Look at the API for [`DateComponents`](https://developer.apple.com/documentation/foundation/datecomponents?language=objc) for creating a specific time
let myDeparture = DepartureBoard(destination: "West Palm Beach", airline: "Turkish Airlines", departureTime: "6:00am", terminal: 5, status: .route, flights: [] )

var flight1 = Flight(pilots: 2, attendants: 2, passengers: 200, ticketClass: "Economy")
var flight2 = Flight(pilots: 2, attendants: 4, passengers: 100, ticketClass: "Business")
var flight3 = Flight(pilots: 2, attendants: 4, passengers: 20, ticketClass: "First Class")

myDeparture.flights.append(flight1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great way to append in to your class without creating a new variable. Good job.

myDeparture.flights.append(flight2)
myDeparture.flights.append(flight3)

//: ## 3. Create a free-standing function that can print the flight information from the `DepartureBoard`
//: a. Use the function signature: `printDepartures(departureBoard:)`
Expand All @@ -40,8 +99,21 @@ import UIKit
//: c. Make your `FlightStatus` enum conform to `String` so you can print the `rawValue` String values from the `enum`. See the [enum documentation](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html).
//:
//: d. Print out the current DepartureBoard you created using the function
enum OtherFlighStatus: CaseIterable {
case EnRoute, Scheduled, Canceled, Delayed, Boarding
}


let numberOfChoices = OtherFlighStatus.allCases.count
print(numberOfChoices)


func printDepartures() {
for flights in OtherFlighStatus.allCases {
print(flights)
}
}
printDepartures()


//: ## 4. Make a second function to print print an empty string if the `departureTime` is nil
Expand Down