From 6c84bb23b7fbf55e946e824d8f07fea89667b536 Mon Sep 17 00:00:00 2001 From: ericgiannini Date: Sun, 4 Dec 2016 18:11:27 -0800 Subject: [PATCH] Update to Xcode 8.0 and Swift 3.0 --- SpaceAdventure/HelperFunctions.swift | 6 +++--- SpaceAdventure/SpaceAdventure.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SpaceAdventure/HelperFunctions.swift b/SpaceAdventure/HelperFunctions.swift index 0275a9c..9e5dfd8 100644 --- a/SpaceAdventure/HelperFunctions.swift +++ b/SpaceAdventure/HelperFunctions.swift @@ -10,8 +10,8 @@ import Foundation // Wait for the user to type something in the console, and return what // they type as a String with the trailing newline character removed. func getln() -> String { - let stdin = NSFileHandle.fileHandleWithStandardInput() - var input = NSString(data: stdin.availableData, encoding: NSUTF8StringEncoding) - input = input!.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet()) + let stdin = FileHandle.withStandardInput + var input = NSString(data: stdin.availableData, encoding: String.Encoding.utf8) + input = input!.trimmingCharacters(in: CharacterSet.newlines) return input as! String } diff --git a/SpaceAdventure/SpaceAdventure.swift b/SpaceAdventure/SpaceAdventure.swift index 6a98a10..5dd319f 100644 --- a/SpaceAdventure/SpaceAdventure.swift +++ b/SpaceAdventure/SpaceAdventure.swift @@ -24,22 +24,22 @@ class SpaceAdventure { } } - private func displayIntroduction() { + fileprivate func displayIntroduction() { print("Welcome to the \(planetarySystem.name)!") print("There are \(planetarySystem.planets.count) planets to explore.") } - private func responseToPrompt(prompt: String) -> String { + fileprivate func responseToPrompt(_ prompt: String) -> String { print(prompt) return getln() } - private func greetAdventurer() { + fileprivate func greetAdventurer() { let name = responseToPrompt("What is your name?") print("Nice to meet you, \(name). My name is Eliza, I'm an old friend of Siri.") } - private func determineDestination() { + fileprivate func determineDestination() { var decision = "" // Start with empty String while !(decision == "Y" || decision == "N") { decision = responseToPrompt("Shall I randomly choose a planet for you to visit? (Y or N)") @@ -58,7 +58,7 @@ class SpaceAdventure { } } - private func visit(planetName: String) { + fileprivate func visit(_ planetName: String) { print("Traveling to \(planetName)...") for planet in planetarySystem.planets { if planetName == planet.name { @@ -67,4 +67,4 @@ class SpaceAdventure { } } -} \ No newline at end of file +}