This file contains a summary of the information in lab02.html. That file contains the lab instructions and should be opened in a browser so you can see all the images.
In this lab we will:
- Practise using git
- Implement a class in Swift
- Write a progam that creates and uses object instances of that class
- Learn about class properties, methods, initialisation, access control and mutability
During the lab, we're going to be getting you to practise committing small changes. So, before you start, you'll need to:
- Create a private
lab02-classes-and-objects
repo in your GitHub account - Run
git remote set-url origin <new repo uri>
- Run
git remote add upstream git@github.com:oucs-cosc346-s2-2018/lab02-classes-and-objects.git
- Run
git push -u origin master
This performs the same steps as we did in last weeks lab. This allows you to
write the changes to your repo, while still being able to pull any changes from
the upstream repo (using git pull upstream master
-- there should be no
changes at this stage).
When you push you may find that you're asked for a username/password or that there's something wrong with the ssh key. I like to use the ssh option with git (as I can setup ssh keys to manage authentication).
Check if the file ~/.ssh/id_rsa.pub
exists, if not, then create a ssh-keypair
using ssh-keygen
, and accept the defaults (you can set a key passphrase or
not -- I've not done that). Once the keypair exists, copy the public key into
the clipboard: cat ~/.ssh/id_rsa.pub | pbcopy
. Go into your github account
settings and find the SSH and GPG key option. Click on New SSH Key
in the top
right, and paste (command + v) into the Key box (set the title to something
you'll remember -- such as "CS Undergrad Lab"). Save the changes and try to
push again -- you should be successful this time.
If you get stuck, talk to one of the teaching team and they'll help you with this.