diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..336400b Binary files /dev/null and b/.DS_Store differ diff --git a/01 Playground Basics/PlaygroundBasics.playground/Pages/Calculations.xcplaygroundpage/Contents.swift b/01 Playground Basics/PlaygroundBasics.playground/Pages/Calculations.xcplaygroundpage/Contents.swift index d097c36..f9e74ff 100644 --- a/01 Playground Basics/PlaygroundBasics.playground/Pages/Calculations.xcplaygroundpage/Contents.swift +++ b/01 Playground Basics/PlaygroundBasics.playground/Pages/Calculations.xcplaygroundpage/Contents.swift @@ -20,3 +20,9 @@ //: Next, learn how programmers can leave notes in code. //: //:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next) +4 + 5 +9 - 3 + + + + diff --git a/01 Playground Basics/PlaygroundBasics.playground/Pages/Comments.xcplaygroundpage/Contents.swift b/01 Playground Basics/PlaygroundBasics.playground/Pages/Comments.xcplaygroundpage/Contents.swift index 2c29e92..fea10b6 100644 --- a/01 Playground Basics/PlaygroundBasics.playground/Pages/Comments.xcplaygroundpage/Contents.swift +++ b/01 Playground Basics/PlaygroundBasics.playground/Pages/Comments.xcplaygroundpage/Contents.swift @@ -19,3 +19,9 @@ //: Take a deep breath and move on to the next page. //: //:[Previous](@previous) | page 4 of 7 | [Next: When Things Go Wrong 😰](@next) +/* HELLO + THIS + IS + HAJAR + WRITING + */ diff --git a/01 Playground Basics/PlaygroundBasics.playground/Pages/Errors.xcplaygroundpage/Contents.swift b/01 Playground Basics/PlaygroundBasics.playground/Pages/Errors.xcplaygroundpage/Contents.swift index 5bb92de..4371ef2 100644 --- a/01 Playground Basics/PlaygroundBasics.playground/Pages/Errors.xcplaygroundpage/Contents.swift +++ b/01 Playground Basics/PlaygroundBasics.playground/Pages/Errors.xcplaygroundpage/Contents.swift @@ -3,7 +3,8 @@ //: This playground page, for example, has an error in it. //: //: 👈 Notice the red error symbol to the left of the line below. This is how a playground tells you where a problem is. -1000 / 0 +1000 / 10 + //: Since there is an error, the playground stops running your code.\ //: Notice that there are no results displayed in the sidebar. 👉 2 + 2 @@ -19,3 +20,7 @@ //: Next, read all about your very recent past. //: //:[Previous](@previous) | page 6 of 7 | [Next: Wrapup](@next) +1000 / 5 + + + diff --git a/01 Playground Basics/PlaygroundBasics.playground/Pages/What Is a Playground?.xcplaygroundpage/Contents.swift b/01 Playground Basics/PlaygroundBasics.playground/Pages/What Is a Playground?.xcplaygroundpage/Contents.swift index 1ae0460..d95e388 100644 --- a/01 Playground Basics/PlaygroundBasics.playground/Pages/What Is a Playground?.xcplaygroundpage/Contents.swift +++ b/01 Playground Basics/PlaygroundBasics.playground/Pages/What Is a Playground?.xcplaygroundpage/Contents.swift @@ -8,25 +8,9 @@ //: //: For negative numbers use the minus sign: -1200 -/*: -Notice how the numbers also show up in the gray area to the right? 👉 - -That area is called the _results sidebar_. As you add or change code, the playground runs your code again and updates the results in the sidebar. - -- experiment: - - Click a line of code to move the cursor there. - - Type to start editing code. - - Change the numbers a few times. - - Add a few new numbers, each on a separate line.\ -Notice that every time you make a change the results are updated in the sidebar. - - - - -Next, find out how to put the results sidebar to better use. - - [Previous](@previous) | page 2 of 7 | [Next: Calculations](@next) -*/ +5 +5 +4 diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/09-ExerciseShow.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/09-ExerciseShow.xcplaygroundpage/Contents.swift index e748d8a..76823d2 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/09-ExerciseShow.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/09-ExerciseShow.xcplaygroundpage/Contents.swift @@ -22,7 +22,14 @@ (150 * 10) - (1000 + 40) //: - callout(Exercise): Using the code above as a reference, use let statements to define constants to better solve your friend’s problem.\ //:Add your code below. To help you get started, the constant `numberOfTickets` is already defined. -let numberOfTickets = 150 //: //:[Previous](@previous) | page 10 of 14 | [Next: Exercise: Lottery Tickets](@next) +let numberOfTickets = 150 +let TicketPrice = 10 +let RoomRentalFee = 1000 +let PosterCost = 40 +let TotalTicketValue = 150 * 10 +let TotalExpenses = 1000 + 40 +let TotalIncomeOfShow = (150 * 10) - (1000 + 40) + diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/10-ExerciseLottery.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/10-ExerciseLottery.xcplaygroundpage/Contents.swift index d2bf006..678fd2d 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/10-ExerciseLottery.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/10-ExerciseLottery.xcplaygroundpage/Contents.swift @@ -31,3 +31,23 @@ let programmersCut = profit / 10 // This is the answer you want to get over 100! let friendsCut = profit - programmersCut //:[Previous](@previous) | page 11 of 14 | [Next: Exercise: What Fits on Your iPhone?](@next) +let theTicketsSold = 900 +let theTicketPrice = 3 +let thePrintingCosts = 18 +let theAdvertising = 40 + +// Total takings +let theTotalTakings = theTicketPrice * theTicketsSold + +// Jackpot +let Thejackpot = theTotalTakings / 2 + +// Expenses +let TheTotalExpenses = thePrintingCosts + theAdvertising + +// Profit +let TheProfit = theTotalTakings - Thejackpot - TheTotalExpenses + +// Distribution +let theProgrammersCut = TheProfit / 10 // This is the answer you want to get over 100! 👉 +let theFriendsCut = TheProfit - theProgrammersCut diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/11-ExerciseiPhone.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/11-ExerciseiPhone.xcplaygroundpage/Contents.swift index 9830483..2f3f8cf 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/11-ExerciseiPhone.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/11-ExerciseiPhone.xcplaygroundpage/Contents.swift @@ -16,8 +16,10 @@ _Hint_: Do all of your calculations in megabytes (MB). */ - - - - //:[Previous](@previous) | page 12 of 14 | [Next: Exercise: Fixing Your Morning](@next) +let IphoneStorage = 8 * 1000 // convert from GB to MB +let IphoneOcuppiedStorage = 3 * 1000 //convert from GB to MB +let IphoneFreeStorage = IphoneStorage - IphoneOcuppiedStorage +let OneMinute = 150 +let MinutesTakenToFullStorage = OneMinute * IphoneFreeStorage + diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/12-ExerciseMorning.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/12-ExerciseMorning.xcplaygroundpage/Contents.swift index a5bbc47..97cfff7 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/12-ExerciseMorning.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/12-ExerciseMorning.xcplaygroundpage/Contents.swift @@ -5,7 +5,7 @@ - callout(Exercise): Create a constant for each activity you do in the morning before leaving home: things like `brushTeeth`, `uploadPhotos`, `chooseClothes`, `shower`, `goJogging`, `finishHomework`, `fixLunch`, and so on. Think about how many minutes each activity usually takes, and assign that value to each constant. */ -let brushTeeth = 3 + // Add more here... //: - callout(Exercise): Find the total time of all the activities by adding up the constants. Try to adjust the values or add more activities until the total time looks reasonably close to the actual amount of time you spend getting ready on an average day. @@ -20,6 +20,7 @@ let brushTeeth = 3 + /*: See what happens to your total time spent getting ready if you tweak the durations of the different activities. How short of a shower would you have to take in order to have more time to message your friends? Or go for a longer run? How much more time would you need if you decided to spend as long as you wanted doing all the activities you like best? @@ -31,3 +32,24 @@ let brushTeeth = 3 //:[Previous](@previous) | page 13 of 14 | [Next: Exercise: Good Names](@next) +//1st ex +let brushTeeth = 2 +let uploadPhotos = 0 +let chooseClothes = 10 +let shower = 15 +let goJogging = 20 +let finishHomework = 50 +let fixLunch = 10 + + +//2nd ex +let totalTime = brushTeeth + uploadPhotos + chooseClothes + shower + goJogging + finishHomework + fixLunch + + +//3rd ex: +let thingsIhaveToDo = shower + brushTeeth + finishHomework +let thingsIlikeToDo = goJogging + chooseClothes + uploadPhotos +let thingsIhateToDo = fixLunch + + + diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/13-ExerciseNaming.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/13-ExerciseNaming.xcplaygroundpage/Contents.swift index 4ba787e..f01ad01 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/13-ExerciseNaming.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/13-ExerciseNaming.xcplaygroundpage/Contents.swift @@ -41,3 +41,15 @@ let rhso = co - lhso _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._ */ //:[Previous](@previous) | page 14 of 14 +let CountOfOranges = 14 +let CountOfWatermelons = 3 +let OrangesWeight = 100 +let WatermelonsWeight = 200 +let TotalOranges = CountOfOranges * OrangesWeight +let TotalWatermelons = CountOfWatermelons * WatermelonsWeight +let Total = OrangesWeight + WatermelonsWeight +let EachSide = Total / 2 +let LeftHandSideOranges = EachSide / OrangesWeight +let RightHandSideOranges = CountOfOranges - LeftHandSideOranges + + diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/Identifiers.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/Identifiers.xcplaygroundpage/Contents.swift index 277161c..03b1b8a 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/Identifiers.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/Identifiers.xcplaygroundpage/Contents.swift @@ -12,9 +12,16 @@ let numberOfTurtles = 2 + 1 let numberOfHamsters = 1 + 1 -let totalNumberOfAnimals = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters +let numberOfPigs = 1 + +let numberOfFishes = 1 + +let numberOfSnakes = 1 + +let totalNumberOfAnimals = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numberOfPigs + numberOfFishes + numberOfSnakes + +let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters + numberOfPigs -let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters //: - experiment: There are even more changes in the pets expected at the pet show.\ //:To add new kinds of animals, add new lines of code that define new constants. (To add a new line of code just click on a blank line in the area above and start typing.) diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/Naming Things.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/Naming Things.xcplaygroundpage/Contents.swift index 6f3f490..bdde257 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/Naming Things.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/Naming Things.xcplaygroundpage/Contents.swift @@ -35,3 +35,14 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters //: Once you’re finished experimenting, move ahead. //: //:[Previous](@previous) | page 4 of 14 | [Next: Typing Names and Autocompletion](@next) +let TheNumberOfDogs = 6 + 2 + +let TheNumberOfCats = 5 - 1 + +let TheNumberOfTurtles = 2 + 1 + +let TheNumberOfHamsters = 1 + 1 + +let TheTotalNumberOfAnimals = TheNumberOfDogs + TheNumberOfCats + TheNumberOfTurtles + TheNumberOfHamsters +let TheTotalNumberOfMammals = TheNumberOfDogs + TheNumberOfCats + TheNumberOfHamsters + diff --git a/02 Naming and Indentifiers/Naming.playground/Pages/Pet Problem.xcplaygroundpage/Contents.swift b/02 Naming and Indentifiers/Naming.playground/Pages/Pet Problem.xcplaygroundpage/Contents.swift index cee5e0a..1ab1633 100644 --- a/02 Naming and Indentifiers/Naming.playground/Pages/Pet Problem.xcplaygroundpage/Contents.swift +++ b/02 Naming and Indentifiers/Naming.playground/Pages/Pet Problem.xcplaygroundpage/Contents.swift @@ -34,3 +34,22 @@ //: Could there be a better way to solve this problem? Think about it for a minute or two, then move on. //: //:[Previous](@previous) | page 2 of 14 | [Next: Pet Problem Recap](@next) +// Number Of Dogs +6 + +// Number Of Cats +5 + +// Number Of Turtles +2 + +// Number Of Hamsters +1 + +// Total Number Of Animals +6 + 5 + 2 + 1 + +// Total Number Of Mammals +6 + 5 + 1 + + diff --git a/03 Strings/Strings.playground/Pages/Combining Strings.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Combining Strings.xcplaygroundpage/Contents.swift index 8be7569..35e2d90 100644 --- a/03 Strings/Strings.playground/Pages/Combining Strings.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Combining Strings.xcplaygroundpage/Contents.swift @@ -35,3 +35,24 @@ let finishedMessage = username + " " + likesYourPostMessage //: Next, find out how building strings by adding them can get complicated. //: //:[Previous](@previous) | page 5 of 16 | [Next: Fill In The Blanks](@next) +// Declare a firstName constant + +let firstName : String = "Hajar" //by defult the compiler will know its a string from the double quotation but i write (: Sring) just in case :) + + +// Declare a lastName constant + +let lastName : String = "Alatawi" + + +// Combine the strings into a fullName constant + +let fullName : String = firstName + " " + lastName + + +// Combine your first name with likesYourPostMessage + +let likesYourPostMessage2 : String = "\(firstName) likes your post" + + + diff --git a/03 Strings/Strings.playground/Pages/Defining Strings.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Defining Strings.xcplaygroundpage/Contents.swift index b06247c..18f918b 100644 --- a/03 Strings/Strings.playground/Pages/Defining Strings.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Defining Strings.xcplaygroundpage/Contents.swift @@ -9,10 +9,14 @@ let traditionalGreeting = "Hello, world!" //: - experiment: Practice by declaring `favoriteMovie` and `favoriteSong` string constants for your favorite movie and song: // Declare a favoriteMovie constant - // Declare a favoriteSong constant //: Next, take a string-based trip around the world. //: //:[Previous](@previous) | page 3 of 16 | [Next: Unicode](@next) +// Declare a favoriteMovie constant +let favoriteMovie = "Home Alone" + +// Declare a favoriteSong constant +let favoriteSong = "Imagine by: John Lennon" diff --git a/03 Strings/Strings.playground/Pages/Exercise-A Restaurant.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Exercise-A Restaurant.xcplaygroundpage/Contents.swift index 79b569b..d52313e 100644 --- a/03 Strings/Strings.playground/Pages/Exercise-A Restaurant.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Exercise-A Restaurant.xcplaygroundpage/Contents.swift @@ -26,6 +26,7 @@ let customerOrderSix = "小笼包" - callout(Exercise): Make sure the server repeats the order correctly *without* copying and pasting or retyping any of the orders. */ + let serverResponseToTableTwo = "Let me make sure I've got this right: " let tableTwoResponse = "Perfect, merci bien." @@ -34,3 +35,39 @@ let tableTwoResponse = "Perfect, merci bien." //: //:[Previous](@previous) | page 14 of 16 | [Next: Exercise: Go! Fight! Win!](@next) +// T1: + +let theserverResponseToTableOne = "Let me make sure I've got this right: \(customerOrderOne). Is that everything?" + +let tableOneResponse1 = "Yes, thank you!" + + +// T2: + +let theserverResponseToTableTwo = "Let me make sure I've got this right: \(customerOrderTwo). Is that everything?" + +let tableTwoResponse2 = "Perfect, merci bien." + + +// T3: +let serverResponseToTableThree = "Let me make sure I've got this right: \(customerOrderThree) . Is that everything?" + +let tableThreeResponse = "yeah, thanks!" + +// T4: + +let serverResponseToTableFour = "Let me make sure I've got this right: \(customerOrderFour) . Is that everything?" + +let tableFourResponse = "Yes, thank you!" + +// T5: + +let serverResponseToTableFive = "Let me make sure I've got this right: \(customerOrderFive) . Is that everything?" + +let tableFiveResponse = "Yup, thanks!" + +// T6: + +let serverResponseToTableSix = "Let me make sure I've got this right: \(customerOrderSix) . Is that everything?" + +let tableSixResponse = "yes, thanks!" diff --git a/03 Strings/Strings.playground/Pages/Exercise-Displaying Values.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Exercise-Displaying Values.xcplaygroundpage/Contents.swift index cbb0924..74e57ce 100644 --- a/03 Strings/Strings.playground/Pages/Exercise-Displaying Values.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Exercise-Displaying Values.xcplaygroundpage/Contents.swift @@ -31,3 +31,11 @@ _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._ */ //:[Previous](@previous) | page 16 of 16 +let IphoneStorage = 8 * 1000 // convert from GB to MB +let IphoneOcuppiedStorage = 3 * 1000 //convert from GB to MB +let IphoneFreeStorage = IphoneStorage - IphoneOcuppiedStorage +let OneMinute = 150 +let MinutesTakenToFullStorage = OneMinute * IphoneFreeStorage +let result = "You can record \(MinutesTakenToFullStorage) more minutes of video." +print (result) + diff --git a/03 Strings/Strings.playground/Pages/Exercise-Go! Fight! Win!.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Exercise-Go! Fight! Win!.xcplaygroundpage/Contents.swift index edcc1ae..36bbca9 100644 --- a/03 Strings/Strings.playground/Pages/Exercise-Go! Fight! Win!.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Exercise-Go! Fight! Win!.xcplaygroundpage/Contents.swift @@ -26,3 +26,9 @@ let song = "\(refrain)\n\(refrain)\nYes, \(refrain)" //: //:[Previous](@previous) | page 15 of 16 | [Next: Exercise: Displaying Values](@next) +let theschoolName = "King Abdulaziz" +let refrain_ = "hmm hmm HMMM hm-hmm \(theschoolName) hmm hmm HMMMMM" + +let thesong = "\(refrain_)\n\(refrain_)\nYes, \(refrain_)" + +print(thesong) diff --git a/03 Strings/Strings.playground/Pages/Exercise-Making a List.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/Exercise-Making a List.xcplaygroundpage/Contents.swift index 59607e3..bf10222 100644 --- a/03 Strings/Strings.playground/Pages/Exercise-Making a List.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/Exercise-Making a List.xcplaygroundpage/Contents.swift @@ -13,9 +13,14 @@ let newline = "Making new lines" - experiment: Make a new string constant that is a list of the things you’ve learned, with each entry on a new line. Make sure you add the result to the playground page so that you can see the list properly. */ - - - - //: //:[Previous](@previous) | page 13 of 16 | [Next: Exercise: A Restaurant](@next) +let thignsIHaveLearned = """ +\(constants) +\(unicode) +\(combining) +\(interpolation) +\(escaping) +\(newline) +""" +print (thignsIHaveLearned) diff --git a/03 Strings/Strings.playground/Pages/More Than Strings.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/More Than Strings.xcplaygroundpage/Contents.swift index 8d2ee9e..7f64b34 100644 --- a/03 Strings/Strings.playground/Pages/More Than Strings.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/More Than Strings.xcplaygroundpage/Contents.swift @@ -7,13 +7,13 @@ let overtimeSaves = 2 let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSaves) saves in the first half, \(secondHalfSaves) in the second half and \(overtimeSaves) saves in overtime, for a total of \(firstHalfSaves + secondHalfSaves + overtimeSaves) saves." //: /*: -- experiment: People have been playing fun fill-in-the-blank games for a long time. You can create a basic version of this kind of game in the playground: - - Make up a short fill-in-the-blank story, or use the one below. - - Create a string or number constant for every blank. - - Use string interpolation to fill in the blanks in the story. + - experiment: People have been playing fun fill-in-the-blank games for a long time. You can create a basic version of this kind of game in the playground: + - Make up a short fill-in-the-blank story, or use the one below. + - Create a string or number constant for every blank. + - Use string interpolation to fill in the blanks in the story. - Sample story: “Today was a big day for . They had finally saved up dollars and were going to buy a . They went to the feeling very . But then they felt . They were all out of !” -*/ + Sample story: “Today was a big day for . They had finally saved up dollars and were going to buy a . They went to the feeling very . But then they felt . They were all out of !” + */ // Add your version of the story below @@ -23,3 +23,20 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa //: Next you’ll see a few more tricks with strings. //: //:[Previous](@previous) | page 9 of 16 | [Next: The Great Escape](@next) +let name = "Hajar" +let number = 100 +let adjective = "amazing" +let noun = "jeans" +let noun2 = "Zara" +let place = "shop" +let positiveEmotion = "happy" +let negativeEmotion = "Disappointed" +let noun3 = "stock" + +let fullStory: String = """ +Today was a big day for \(name). +They had finally saved up \(number) dollars and were going to buy a \(adjective + noun). +They went to the \(noun2 + place) feeling very \(positiveEmotion). +But then they felt \(negativeEmotion). They were all out of \(noun3)! +""" +print(fullStory) diff --git a/03 Strings/Strings.playground/Pages/String Interpolation.xcplaygroundpage/Contents.swift b/03 Strings/Strings.playground/Pages/String Interpolation.xcplaygroundpage/Contents.swift index cd184be..3c91001 100644 --- a/03 Strings/Strings.playground/Pages/String Interpolation.xcplaygroundpage/Contents.swift +++ b/03 Strings/Strings.playground/Pages/String Interpolation.xcplaygroundpage/Contents.swift @@ -25,3 +25,13 @@ let reason = "tasty" //: On the next page, see what happens with long strings. //: //:[Previous](@previous) | page 7 of 16 | [Next: Viewing Playground Results](@next) +// Change this to your favorite food +let MyfavoriteFood = "Pizza" + +// Change this to why you like it +let thereason = "Delicious" + +// Define a string below in the pattern "I like ___ because it is ___." + +let thefavfood = "I like \(MyfavoriteFood), because it is \(thereason)" + diff --git a/04 Functions/Functions.playground/Pages/A Single Piece of Work.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/A Single Piece of Work.xcplaygroundpage/Contents.swift index 6071c5e..e6b14ba 100644 --- a/04 Functions/Functions.playground/Pages/A Single Piece of Work.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/A Single Piece of Work.xcplaygroundpage/Contents.swift @@ -36,3 +36,12 @@ func rowTheBoat() { //: Next, learn about how to think about tasks and divide them up in a way that makes sense. //: //: [Previous](@previous) | page 4 of 12 | [Next: Breaking It Down](@next) +func sum () { + let num1 = 2 + let num2 = 5 + let result1 = num1 + num2 + print(result1) + +} +sum() + diff --git a/04 Functions/Functions.playground/Pages/Breaking it Down.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Breaking it Down.xcplaygroundpage/Contents.swift index 382007d..b774974 100644 --- a/04 Functions/Functions.playground/Pages/Breaking it Down.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Breaking it Down.xcplaygroundpage/Contents.swift @@ -42,3 +42,9 @@ rowTheBoat() //: Next, learn about making larger groups of tasks. //: //: [Previous](@previous) | page 5 of 12 | [Next: Functions Within Functions](@next) +func crocodileScream() { + breatheBetweenVerses() + rowTheBoat() + + +} diff --git a/04 Functions/Functions.playground/Pages/Change Something Once.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Change Something Once.xcplaygroundpage/Contents.swift index 593fac2..ef633ae 100644 --- a/04 Functions/Functions.playground/Pages/Change Something Once.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Change Something Once.xcplaygroundpage/Contents.swift @@ -46,3 +46,28 @@ verseThree() [Previous](@previous) | page 9 of 12 | [Next: Wrapup](@next) */ +func rowTheBoat1() { + print("Ride, ride, ride your bike") + print("With your cycling team") +} + +func verseOne1() { + rowTheBoat1() + merrilyDream() +} + +func verseTwo2() { + rowTheBoat1() + crocodileScream() +} + +func verseThree3() { + rowTheBoat1() + repetitiveTheme() +} + +verseOne1() +breatheBetweenVerses() +verseTwo2() +breatheBetweenVerses() +verseThree3() diff --git a/04 Functions/Functions.playground/Pages/Functions Within Functions.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Functions Within Functions.xcplaygroundpage/Contents.swift index 559c1a9..201a6bc 100644 --- a/04 Functions/Functions.playground/Pages/Functions Within Functions.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Functions Within Functions.xcplaygroundpage/Contents.swift @@ -29,13 +29,28 @@ verseOne() - callout(Exercise): Write a function for an alternate second verse of the song using the laughing submarine function below. */ func laughingSubmarine() { + print("Ha! Ha! Fooled you all") print("I’m a submarine") } + // Write the verse two function below //: On the next page, learn about one of the things that can go wrong when using functions of functions. //: //: [Previous](@previous) | page 6 of 12 | [Next: Infinite Loops](@next) + +func laughingSubmarine1 () { + print("Merrily, merrily, merrily, merrily") + print("Life is but a dream") +} + +func verseTwo(){ + laughingSubmarine1() + +} + verseTwo() + + diff --git a/04 Functions/Functions.playground/Pages/Hiding Complexity.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Hiding Complexity.xcplaygroundpage/Contents.swift index 264877a..9cbcd4d 100644 --- a/04 Functions/Functions.playground/Pages/Hiding Complexity.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Hiding Complexity.xcplaygroundpage/Contents.swift @@ -17,3 +17,12 @@ verseThree() [Previous](@previous) | page 8 of 12 | [Next: Change Something Once](@next) */ +// I write the functions on a different order + I copy some of them +breatheBetweenVerses() +verseThree() +verseOne() +breatheBetweenVerses() +verseTwo() +breatheBetweenVerses() +verseThree() +breatheBetweenVerses() diff --git a/04 Functions/Functions.playground/Pages/Infinite Loops.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Infinite Loops.xcplaygroundpage/Contents.swift index 0c00804..606c3d1 100644 --- a/04 Functions/Functions.playground/Pages/Infinite Loops.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Infinite Loops.xcplaygroundpage/Contents.swift @@ -25,6 +25,7 @@ func verseOne() { verseOne() + /*: - experiment: Make an infinite loop in the code above by editing the `verseOne` function, so it calls `verseOne()` after it calls `merrilyDream()`. Look at the console and the results sidebar. Remove the line to stop the loop. It might take a while until the playground recovers – infinite loops are hard work. @@ -32,3 +33,21 @@ verseOne() [Previous](@previous) | page 7 of 12 | [Next: Hiding Complexity](@next) */ +func rowTheBoat1() { + print("Row, row, row your boat") + print("Gently down the stream") +} + +func merrilyDream1() { + print("Merrily, merrily, merrily, merrily") + print("Life is but a dream") +} + +func verseOne1() { + verseOne1() + merrilyDream1() +} + +verseOne1() + + diff --git a/04 Functions/Functions.playground/Pages/Meme Exercise.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Meme Exercise.xcplaygroundpage/Contents.swift index a08cd0b..56be690 100644 --- a/04 Functions/Functions.playground/Pages/Meme Exercise.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Meme Exercise.xcplaygroundpage/Contents.swift @@ -30,3 +30,19 @@ //: Next, make the meme your own. //: //: [Previous](@previous) | page 11 of 12 | [Next: Personal Meme](@next) +// My fav song by: Beyoncé +func song (){ +print("you know you're my saving grace") +print("You're everything I need and more") +print("It's written all over your face") +print("Baby, I can feel your halo") +print("Pray it won't fade away") +print("I can feel your halo (halo) halo") +print("I can see your halo (halo) halo") +print("I can feel your halo (halo) halo") +print("I can see your halo (halo) halo") +} +func favsong (){ + song() +} +favsong() diff --git a/04 Functions/Functions.playground/Pages/Personal Meme.xcplaygroundpage/Contents.swift b/04 Functions/Functions.playground/Pages/Personal Meme.xcplaygroundpage/Contents.swift index 216203e..2d8fdcb 100644 --- a/04 Functions/Functions.playground/Pages/Personal Meme.xcplaygroundpage/Contents.swift +++ b/04 Functions/Functions.playground/Pages/Personal Meme.xcplaygroundpage/Contents.swift @@ -24,7 +24,6 @@ - /*: _Copyright © 2017 Apple Inc._ @@ -36,3 +35,21 @@ _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._ */ //: [Previous](@previous) | page 12 of 12 +func song1 (){ +print("you know you're NOT my saving grace") +print("You're everything BUT OTHER THAN THAT") +print("It's written all over your face") +print("Baby, I can'T feel your halo") +print("Pray it fade away") +print("I can'T feel your halo (halo) halo") +print("I can'T see your halo (halo) halo") +print("I can'T feel your halo (halo) halo") +print("I can'T see your halo (halo) halo") +} +func favsong1 (){ + song1() + +} +favsong1() + +