We will spend a few week revising L2 concepts. These include:
The way we will revise these concepts is by using a variety of resources, including an online system called Repl.it. This course has lots of problems (about 120), you are free to do them all, but it really is not necessary.
Otago Workbook L3
https://drive.google.com/open?id=0BzdQz45DMVPtaUlpR29RZVpOcG8
Otago Workbook L2
https://drive.google.com/open?id=0BzdQz45DMVPtYlZQOVlOY3Mxc0E
How to think like a computer scientist (HTTLACS) - Java version
https://drive.google.com/open?id=1EwMU0TZnfvzpL8j-6ZQDaTdR9LvOKtda
Online version (but not interactive)
https://books.trinket.io/thinkjava/
Otago Workbook L3 https://drive.google.com/file/d/0BzdQz45DMVPtNFFJVWw1WWF4aGs
Otago workbook L2 https://drive.google.com/file/d/1WLiQlacS-Q5o5M3S7Oc4lE1UIuEet86G
How to think like a Computer Scientist - Python Version http://www.greenteapress.com/thinkpython/thinkCSpy.pdf
How to think like a computer scientist -HTTLACS interactive version
https://interactivepython.org/courselib/static/thinkcspy/index.html
The java cheat sheet outlined below is also very useful - find it at https://introcs.cs.princeton.edu/java/11cheatsheet/
The learning aims for this week are to revise/understand:
We'll Start off by revising some simple programming concepts. You'll need to open up the L2 Otago workbook.
We are going to revise/relearn about types of data and variables - you will need to read chapters 1 & 2.
Also, the HTLACS website - chapter 2 covers the same material - again, read these 2 chapters - but not the exercises at the end.
The three videos below should get you started. Your aim is to be able to do problem 11 in the spreadsheet below - once you have logged in. For some of you this will be a challenge.
There are a few things you will need -
Problem 7 uses something called charAt()
Problem 8 uses something called indexOf()
Problem 9 uses something called substring()
How to use these is outlined in Chapter 9 of HTTLACS and chapter 8 of the Otago book - you will need to look at these chapters to understand this - don't read thes chapters until you have got to problem 7 as it will be too confusing.
There are also lots of youtube videos on learning Java - feel free to search these out.
Brief explanations of solutions to problems 7 & 11 are below. There are many ways to get these answers - the references I have given you, youtube etc.
The learning aims for this week are to revise/understand:
Again you will need to use the L2 Otago workbook.
We are going to revise/relearn about conditionals (if /else) - you will need to read chapters 5 - have a think about the problems but don't code them.
Also, the HTLACS website - chapter 5 covers the same material (but not 5.8 onwards) - again, read this chapters - but not the exercises at the end.
The three videos below should get you started. Your aim is to be able to do problems 15, 16 17 & 18 - all four in the spreadsheet below - once you have logged in. This is also chance to catch up on last weeks work if you missed out.
There are a few things you will need -
Problem 15 is an if followed by a else if
Problem 16 requires the use of the modulus or remainder operator - there's a short video of this at the bottom.
Problem 17 requires you to compare two Strings to see if they have the same value. There's at trick to this. Look at the video - but also the otago L2 workbook Chapter 8 page 106
Problem 18 this requires you to use substrings and compare them in a series of if/else's. Substrings were covered last week - have a look at pg 104 of the otago L2 book or 9.4 of the HTTLACS site https://books.trinket.io/thinkjava/chapter9.html
There are also lots of youtube videos on learning Java - feel free to search these out.
Answers to the problems (also added as model solutions on repl.it once you have completed the problem).
#18 https://repl.it/@trevorstorr/18
#17 https://repl.it/@trevorstorr/17
#16 https://repl.it/@trevorstorr/16
#15 https://repl.it/@trevorstorr/15
Addition to the above video - note that when you compare Strings you can compare using either the name of the string or the value of a string so if
String carOne = "Mazda";
String carTwo = "Ford";
then (not in strict code)
carOne.equals(carTwo) AND carOne.equals("Ford") will both give the result FALSE
We will now move on to loops - for loops.
The learning aims for this week are to revise/understand:
The problems that are relevant to this are 19, 23, , 28, and 31.
Useful resources to help you out include:
A great explanation of for loops https://funnelgarden.com/java-for-loop/#For_Loop
The above video is a partial solution to #23. It shows how to use || as a logical operator in the conditions of an if statement - within a for loop.
We will now revise modular programming. In Python these are called functions. In Java, they are called methods. They are both exactly the same way of breaking down your program into named sections that serve a particular purpose. We will also cover scope.
In my experience both methods and especially scope cause a lot of misunderstanding when learning to program - there are just so many ideas that need to be understood at the same time.
I've some videos to explain the key concepts. If you want an extra explanation - don't forget the Friday tutorial.
The problems that indicate you understand this are numbers 43, 50 & 60. The ones that you can have a go at are: 36 -> 60 - so there are lots to try out - but remember it is only the 3 in bold that you have to do to show me you understand this.
Useful resources to help you out include:
The repl.it below might help you understand https://repl.it/@trevorstorr/Method-types
Please feel free to copy the code and play around with it.
At this point we have revised almost all of the level 2 programming content - well done!
Revision but also some L3 work
Learning Aims - understand and use the concepts of scope and classes
Scope is a fairly advanced topic that you will now need to have some understanding of. I've made three videos that describe some of these ideas. In reality though, scope is something that is learned by doing - and often through mistakes where something is not working - though you think it should. Take a look at the videos below.
Classes are an integral part of understanding java and also scope in Java.
You'll need to use the L3 Otago book to understand this - see link at the top of this page. Chapter 1 is 39 pages in length - yet all is quite important. You will need to do the program on pg12. The code listings are here and here.
You will need to install something like dr java or netbeans on a laptop to run this.
How to think like a computer scientist - chapters 10 and 11 are also recommended reading here.
Note - this is a fairly difficult section. You may need to return to it several times.
Repls referred to in the lesson:
The key problems in repl.it are 61, 62 and 67 & 68.
In my experience, this takes a while to understand - there is a lot of new ideas to take in.
Learning outcomes:
Last week we introduced the idea of scope and classes. It is a complex concept to understand fully. To give you time for the ideas from last week to mature, we will revise the last Level 2 topic - list type structures.
The reading/ relevant parts in our resources are:
Chapter 7 of the Y12 Otago uni Level 2 book - Arrays
Chapter 3 of the Y13 Otago uni Level 3 book - Array lists
Chapter 8 of the How to think like a computer scientist book - Arrays
Some repls that I use for teaching
Arrays: https://repl.it/@trevorstorr/Java-Arrays
Arraylists: https://repl.it/@trevorstorr/Java-ArrayLists
The relevant problems are: 70, 74, 81, 103,104, 105,106, 107, 110. Only attempt the other problems between 110 and 115 if you are super enthusiastic!