From feb190c1cffb5d2299972a343d4a0805d35d57d1 Mon Sep 17 00:00:00 2001 From: SJDSNL Date: Sat, 10 Feb 2018 16:49:08 +0100 Subject: [PATCH] answers entered --- .../Pages/main.xcplaygroundpage/Contents.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index ebe55fd..f9b1588 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -15,7 +15,7 @@ ### 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 BankBalance: Int = 100 @@ -23,7 +23,7 @@ ### 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 - +let Dog = "Bella" @@ -31,7 +31,7 @@ ### 3. Use the `print()` function to print the name of your new puppy to the console. */ // write your code here - +print(Dog) @@ -40,14 +40,14 @@ */ // write your code here - +print("I just got a new puppy named \(Dog) 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 $\(BankBalance) in my bank account.") @@ -55,15 +55,15 @@ ### 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 - - +BankBalance = BankBalance+100 +print("I now have $\(BankBalance).") /*: 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 - +/* No, this is not possible, since we declared the name Dog as constant "let". This is not changable at a later moment */ /*: 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.