From 66ccb3e9eeb690d9199092b1bcdc2fe7d074e1b8 Mon Sep 17 00:00:00 2001 From: Michael Soares Date: Mon, 7 Jan 2019 23:02:01 -0500 Subject: [PATCH] all about functions --- .../main.xcplaygroundpage/Contents.swift | 78 ++++++++++++------ .../contents.xcworkspacedata | 7 ++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../UserInterfaceState.xcuserstate | Bin 0 -> 12180 bytes 4 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata create mode 100644 MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 MyPlayground.playground/playground.xcworkspace/xcuserdata/michaelsoares.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index 61512aa..3c0a424 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -17,8 +17,10 @@ - - +func frozen(){ + print("Let it go!") +} +frozen() @@ -27,8 +29,11 @@ */ // write your code here - - +func frozenAgain(){ + let now = "Let it go!" + print(now) +} +frozenAgain() @@ -38,6 +43,10 @@ */ // write your code here +func favoriteCharacter(name: String){ + print("My favorite character is \(name).") +} +favoriteCharacter(name: "Ralph") @@ -50,8 +59,10 @@ // write your code here +let newCharacter = favoriteCharacter(name: "King Kong") - +var bestCharacter = favoriteCharacter(name: "Penelope") +var cheese = favoriteCharacter(name: "Mr. Hankey") @@ -61,9 +72,11 @@ // write your code here +func problems(num: Int){ + print("I got \(num) problems but Swift ain't one") +} - - +problems(num: 99) @@ -72,19 +85,22 @@ */ // write your code here - - +func favBand(band: String, num: Int){ + print("My #\(num) favorite band is \(band).") + +} +favBand(band: "CKY", num: 1) /*: question7 ### 7. The code below is broken. Can you identify which line has an error and fix it so that it works again? Uncomment the code below before starting. */ -//func badFavoriteBand(bandName: String, position: Int) { -// print("My #\(position) favorite band is \(bandName).") -//} -// -//badFavoriteBand("The Beatles", 2) +func badFavoriteBand(bandName: String, position: Int) { + print("My #\(position) favorite band is \(bandName).") +} + +badFavoriteBand(bandName: "The Beatles", position: 2) @@ -95,11 +111,11 @@ /*: question8 ### 8. This code is broken, too. Assume the call to the function is correct. What's broken about the function definition? Can you fix it? Uncomment the code below before starting. */ -//func alsoBadFavoriteBand(bandName: String, position: String) { -// print("My #\(position) favorite band is \(bandName)") -//} -// -//alsoBadFavoriteBand(bandName: "Blink-182", position: 42) +func alsoBadFavoriteBand(bandName: String, position: Int) { + print("My #\(position) favorite band is \(bandName)") +} + +alsoBadFavoriteBand(bandName: "Blink-182", position: 42) @@ -112,7 +128,11 @@ */ // write your code here +func madLib(name: String, noun: String, preposition: String){ + print("To \(noun) and \(preposition), \(name)!") +} +madLib(name: "King Kong", noun: "City", preposition: "on" ) @@ -123,9 +143,12 @@ */ // write your code here +func resuce()->String{ + return "Buzz Lightyear to the resuce!" + +} - - +resuce() @@ -135,9 +158,11 @@ // write your code here +func num()-> Int{ + return 347 +} - - +num() /*: question12 ### 12. Create a function that takes in a characters name. This function will return back a `String` as follows: "To infinity and beyond, !". The character name should be returned uppercased. @@ -145,8 +170,11 @@ // write your code here - - +func buzz(name: String)-> String{ + return "To infinity and beyond, \(name)!" + +} +buzz(name: "Woody") //: Click [here](https://github.com/learn-co-curriculum/swift-allAboutFunctions-lab/blob/solution/MyPlayground.playground/Pages/solution.xcplaygroundpage/Contents.swift) for a link to the solution. diff --git a/MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata b/MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/MyPlayground.playground/playground.xcworkspace/xcuserdata/michaelsoares.xcuserdatad/UserInterfaceState.xcuserstate b/MyPlayground.playground/playground.xcworkspace/xcuserdata/michaelsoares.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..f36e709d3e77b40b2bedbd93282c78aec49fb53f GIT binary patch literal 12180 zcmd6NcYKr8_x~M9n^d4_)23O?Xcj2lEiItX4HamCPRgih`?Lhoq$a7QB62I>!i59e z(6STLJBW_VXDhdkjiKvKx@;mo=nzR-DeEI%fzdwHDRoXoF-gD1A^L@^JnmW9m zU??NwJ%kZK6v>brMbYQz^Y!)%gh0^a_to3|O$&tPP;i#r9cZ5KfydSMkiR1y;Y-(T zjl%{MjTA_Y5>O&?ASZI6k!Tb;6P<-JQ7$?g6`&F{6-`4Gs2Vk(*=Qc}qITp%e$;`^ zM*$Q>A=HU3Ko=o~deF7#IS~)?yvj zV*@r~J5I-A@i;sYm*O&fF0R0pcsj1d4R{`I#%*{Z_Tx@`0lo+?!I$C7@fG+=d<|ZQ zdvPCLk2m0rcoW`?@50;gWB76W1bz~4$Is%I@tgQ9{678&@5B4?LHs%X0)K~JiNwUb<ermJ&vK$R%VMSw*fVH;^02O=LB>o!misNgr8H?j~Ew1LQ&S7}-u< zBd?P;$eZLX@-}&g{D*u(_K~m2H{@IL9r>C3PX45rs%ZjEq#Bw;wNyv-G?_Z6le%a& z&7rw;49%nYbSxc5%jh&(L1)q`T21TeEE=RC+DR{1GP;Z|rrzJb4-3=YEE{^*wmtu+|tzC?Bb%_tlXT!u~|9cjWsA4**Bpiq(wTUM+RhMau&s+ znSv=<%qC<)W@JHDl!9#R3>M2&ET4^Kp#1_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