Section 1 Project

Woohoo! You made it through section 1 and now have a good understanding of the fundamentals of Swift! That wasn't so bad, right? Now let's put your skills to the test.


Requirements:

Task 1

  1. Create a new Swift Playground.

  2. Declares a few variables to your Playground of the following types and assign them any valid values:

  3. String

  4. Int

  5. Double

  6. Float

  7. Bool

  8. Write a function which calculates the volume of a cube. It should accept one parameter (side length) and return a value of type Double for the volume. The formula to determine the area of a cube is: V = a^3^

  9. Create an array containing the names of your 4 favorite Pokémon. The values should be of type String.

  10. Write a for-in loop that loops through the Pokémon array and prints "[Pokémon name goes here], I choose you!"

  11. Create a Dictionary that contains the make and model of 4 different cars you like. If you don't like cars, you can use something else. 😀

  12. Create a Boolean variable called downloadFinished and write a conditional statement (if/else) which checks to see if it is true or not and then prints a relevant message.

  13. Create a class called Shoe and give it properties for hasLaces of type Bool, color of type String, and releaseDate of type Int. 9.) Create subclasses of Shoe for three different models of shoes that you like and initialize the variables with the relevant data for each shoe model.

Task 2

  1. Create a folder and put your .playground file in it.
  2. Create a Github account if you haven't already.
  3. Create a new repository on Github.
  4. Follow the guide in Chapter 15 (Setting Up Github) to get your computer's SSH key on Github.
  5. On your computer, from the Terminal app, initialize the folder containing your Playground as a local Git repository.
  6. Add all files and then make a commit with a message.
  7. Add your SSH Github repository URL (click the clipboard button on Github) as a remote repository (remember: git remote add)
  8. Pull from Github (which will merge any files you already have in that repo)
  9. Push to Github

The End Result

If you refresh your repository on github.com you should see the Playground file loaded up on your Github page.