Methods - tstorrnetnz/teaching2022 GitHub Wiki

It was great meeting with you all this week. I am very encouraged by your progress. Remember - any problems at all - don’t hesitate to contact me.

After this week we will have nearly completed revising NCEA level 2. Note that we will have done this very briefly, with only a few problems to show your understanding.

The Friday tutorial is at 11am tomorrow (use the usual zoom meeting room). Who is intending to turn up?

Learning Aims - use java methods to simplify your code

For you to do:

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.

I have a few videos that explain the key ideas.

Introduction to methods - basic concepts

Methods part 1

Methods part 1

Methods part 3

Useful resources to help you out include:

  • Otago Level 2 book - Chapters 2 and especially 3. You should have read chapter 2 already. You will need to thoroughly understand chapter 3.

  • HTTLACS Chapters 4 (especially 4.3 onward) and 6. The part about reading documentation is good. In chapter 6 - all is relevant (except 6.7 recursion - this is Ist year university level and is very interesting for those who wish....).

  • Remember to use the cheatsheet https://introcs.cs.princeton.edu/java/11cheatsheet/ The heading to look out for in the cheat sheet is Functions Java Methods

  • 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!

The problems that indicate you understand this are numbers 43, 50, 58 & 60.

Extension work:

There are also some nice problems below:

https://www.codesdope.com/practice/java-have-your-own-methods/ - but some of these are hard!