Skip to content

Conversation

JamesSedlacek
Copy link

@swift-student
// I wanted to work on this some more to complete all the stretch goals, but just ran out of time

Copy link

@swift-student swift-student left a comment

Choose a reason for hiding this comment

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

Overall, another solid assignment from you, James! You seem to be understanding the material well. You should have no problems with the sprint challenge this weekend.

Comment on lines +131 to +140
func printDepartures2(departureBoard: DepartureBoard) {
for flight in departureBoard.departureFlights {
let flightTerminal = flight.terminal ?? ""
if let departureTime = flight.time {
print("Destination: \(flight.destination) Airline: \(flight.airline) Flight: \(flight.flightID) Departure Time: \(departureTime) Terminal: \(flightTerminal) Status: \(flight.status.rawValue)")
} else {
print("Destination: \(flight.destination) Airline: \(flight.airline) Flight: \(flight.flightID) Departure Time: Terminal: \(flightTerminal) Status: \(flight.status.rawValue)")
}
}
}

Choose a reason for hiding this comment

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

Love what you came up with here. Very clean with only two print statements and using the nil coalescing operator.

Comment on lines +189 to +194
func convertDoubleToCurrency(amount: Double) -> String {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .currency
numberFormatter.locale = Locale.current
return numberFormatter.string(from: NSNumber(value: amount)) ?? ""
}

Choose a reason for hiding this comment

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

Hell yeah! Great helper function! Way to think like a developer.

//: d. Print out the current DepartureBoard you created using the function
func printDepartures(departureBoard: DepartureBoard) {
for flight in departureBoard.departureFlights {
print("The Flight is \(flight.status.rawValue)")

Choose a reason for hiding this comment

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

Nice use of .rawValue

Comment on lines +90 to +91
let orlandoFlight = Flight(status: .Scheduled, terminal: "7",
time: Date(), destination: "Orlando", airline: "Delta Air Lines", flightID: "KL 6966")

Choose a reason for hiding this comment

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

I appreciate the return to keep it from line wrapping. Thoughtful.

Comment on lines +20 to +24
case EnRoute = "En Route"
case Scheduled = "Scheduled"
case Canceled = "Canceled"
case Delayed = "Delayed"
case Boarding = "Boarding"

Choose a reason for hiding this comment

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

Not a huge deal, but enum cases should be lower cased, as they are not a type:

enum FlightStatus: String {
    case enRoute = "En Route"
    case scheduled = "Scheduled"
    case canceled = "Canceled"
    case delayed = "Delayed"
    case boarding = "Boarding"
}

Comment on lines +51 to +72
switch flight.status {
case .Boarding:
if let flightTerminal = flight.terminal {
print("Your flight is boarding, please head to terminal: \(flightTerminal) immediately. The doors are closing soon.")
} else {
print("See the nearest information desk for more details.")
}
case .Canceled:
print("We're sorry your flight to (city) was canceled, here is a $500 voucher")
case .Delayed:
print("We're sorry, your flight is delayed.")
case .EnRoute:
print("Your flight is en route.")
case .Scheduled:
if let flightTime = flight.time {
if let flightTerminal = flight.terminal {
print("Your flight to \(flight.destination) is scheduled to depart at \(flightTime) from terminal: \(flightTerminal)")
} else {
print("See the nearest information desk for more details.")
}
}
}

Choose a reason for hiding this comment

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

Nice switch statement! I will say that convention in Swift is for the cases to be at the same indentation as the switch keyword. ctrl-i in Xcode produces this:

func upcomingFlightAlert(flight: Flight) {
    switch flight.status {
    case .Boarding:
        if let flightTerminal = flight.terminal {
            print("Your flight is boarding, please head to terminal: \(flightTerminal) immediately. The doors are closing soon.")
        } else {
            print("See the nearest information desk for more details.")
        }
    case .Canceled:
        print("We're sorry your flight to (city) was canceled, here is a $500 voucher")
    case .Delayed:
        print("We're sorry, your flight is delayed.")
    case .EnRoute:
        print("Your flight is en route.")
    case .Scheduled:
        if let flightTime = flight.time {
            if let flightTerminal = flight.terminal {
                print("Your flight to \(flight.destination) is scheduled to depart at \(flightTime) from terminal: \(flightTerminal)")
            } else {
                print("See the nearest information desk for more details.")
            }
        }
    }
}

Comment on lines +180 to +187
func calculateAirfare(checkedBags: Int, distance: Int, travelers: Int) -> Double {
let bagCost: Double = 25.00
let costPerMile: Double = 0.10
let totalBagCost = Double(checkedBags) * bagCost
let totalMileCost = Double(distance) * costPerMile
let airfareTotal: Double = (totalBagCost + totalMileCost) * Double(travelers)
return airfareTotal
}

Choose a reason for hiding this comment

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

Very clear and easy to understand your logic here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants