From 58d25cdb68ba1135376343fa0ac8f6793de4c74e Mon Sep 17 00:00:00 2001 From: aralduhin Date: Mon, 14 Jan 2019 18:28:12 +0200 Subject: [PATCH 1/2] answers --- .../main.xcplaygroundpage/Contents.swift | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index ebe55fd..b97281d 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -11,59 +11,38 @@ In the following questions, where we use the term `variable`, we are not specifying whether or not it's a variable that is declared with `var` or a constant which is declared with `let`. We are using this general term, leaving it up to you to decipher whether or not you need to use `var` or `let` within the solution. */ -/*: question1 -### 1. Create a variable which represents your bank account balance. (For example: What is a good name for this variable that makes it easily readable for myself now and for the future me _or_ other developers I might be working with? Should I declare it using `let` or `var`? Should it be of type `Int` or `String`?) -*/ -// write your code here +var myAccountBalance = 30000.54 -/*: question2 -### 2. You went to your local pet store and purchased yourself a puppy. You decided to name the puppy Bella. Once you named her, that name will stick with her forever. Create a variable that stores the name of your new puppy. -*/ -// write your code here +var puppyName = "abaddon" -/*: question3 -### 3. Use the `print()` function to print the name of your new puppy to the console. -*/ -// write your code here +print("\(puppyName)") -/*: question4 -### 4. Use the `print()` function to print the sentence "I just got a new puppy named and she is awesome!" to the console. -*/ -// write your code here +print("I just got a new puppy named '\(puppyName)' and she is awesome!") -/*: question5 -### 5. Use the `print()` function to print the sentence "I have $ in my bank account." to the console. -*/ -// write your code here +print("I have $\(myAccountBalance) in my bank account.") -/*: question6 -### 6. Congratulations! You just got $100 for your birthday, so now you have $100 more in your bank account. Update your bank account with the new balance and print "I now have $." to the console. -*/ -// write your code here +myAccountBalance = myAccountBalance+100 +print("I now have $\(myAccountBalance) in my bank account.") -/*: question7 -### 7. You decided you don't like the name Bella. Change your puppy's name to something else. (Can you do this? What happens when you try? Why?) -*/ -// write your code here - + puppyName = "devil" /*: Checkout the solution branch - git co solution or git checkout solution and then scroll back down to this very spot to see a link that directs you to the solutions to the above questions. From c869c26f1f10e87ccb20de6b75f43519d3685244 Mon Sep 17 00:00:00 2001 From: aralduhin Date: Mon, 14 Jan 2019 18:29:38 +0200 Subject: [PATCH 2/2] restore questions --- .../main.xcplaygroundpage/Contents.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index b97281d..98f11d4 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -11,36 +11,57 @@ In the following questions, where we use the term `variable`, we are not specifying whether or not it's a variable that is declared with `var` or a constant which is declared with `let`. We are using this general term, leaving it up to you to decipher whether or not you need to use `var` or `let` within the solution. */ +/*: question1 +### 1. Create a variable which represents your bank account balance. (For example: What is a good name for this variable that makes it easily readable for myself now and for the future me _or_ other developers I might be working with? Should I declare it using `let` or `var`? Should it be of type `Int` or `String`?) +*/ var myAccountBalance = 30000.54 +/*: question2 +### 2. You went to your local pet store and purchased yourself a puppy. You decided to name the puppy Bella. Once you named her, that name will stick with her forever. Create a variable that stores the name of your new puppy. +*/ var puppyName = "abaddon" +/*: question3 +### 3. Use the `print()` function to print the name of your new puppy to the console. +*/ print("\(puppyName)") +/*: question4 +### 4. Use the `print()` function to print the sentence "I just got a new puppy named and she is awesome!" to the console. +*/ print("I just got a new puppy named '\(puppyName)' and she is awesome!") +/*: question5 +### 5. Use the `print()` function to print the sentence "I have $ in my bank account." to the console. +*/ print("I have $\(myAccountBalance) in my bank account.") +/*: question6 +### 6. Congratulations! You just got $100 for your birthday, so now you have $100 more in your bank account. Update your bank account with the new balance and print "I now have $." to the console. +*/ myAccountBalance = myAccountBalance+100 print("I now have $\(myAccountBalance) in my bank account.") +/*: question7 +### 7. You decided you don't like the name Bella. Change your puppy's name to something else. (Can you do this? What happens when you try? Why?) +*/ puppyName = "devil"