COMP110
Jump Around
November 19th, 2015
🐒
Fall 2015 Sections 2 & 3 Sitterson 014 Kris Jordan kris@cs.unc.edu Sitterson 238
Jump Around Kris Jordan Fall 2015 November 19th, 2015 - - PowerPoint PPT Presentation
Go ahead and get todays code in Eclipse as shown on next few slides COMP110 Jump Around Kris Jordan Fall 2015 November 19th, 2015 kris@cs.unc.edu Sections 2 & 3 Sitterson 238 Sitterson 014 Classroom Materials
November 19th, 2015
🐒
Fall 2015 Sections 2 & 3 Sitterson 014 Kris Jordan kris@cs.unc.edu Sitterson 238
If Eclipse won’t let you run:
filters
public static void main(String[] args) { System.out.println( scary(3) ); } static String scary(int howScary) { if(howScary > 1) { return scary(howScary - 1) + "O"; } else { return "B"; } }
mirror” effect photo
It’s a little awkward and hard to get right. It’s really cool when it works. It’ll stretch your mind.
types, but you can use either independently
A gentle introduction to the concept with some hands on exploration.
Let’s write a recursive method… icarus
and then call the icarus method again from within itself.
frame gets added to the top of the call stack.
calling the icarus method
run out of memory and crash
loop from a non-infinite loop?
“Strange Loops”
int aRecursiveMethod(int n) { if(base case condition) { return 1; } else { return aRecursiveMethod(n - 1); } }
stack and return to the method from whence we came
in a loop: it is a condition that ends the repetition
recursive method
have to use recursion for everything (LISP, Scheme, Haskell)
Java will stretch your mind
at all.
room?
A B C D E F G H I J K L M N O
As you walk through each room, write down its letter…
A B C D E F G H I J K L M N O
A B C D E F G H I J K L M N O
A B C E F G H I J K L M N O D $50
Total: $50
A B C D $50 E F G H I J K L M N O
Total: $50
A B C E F G H I J K L M N O D $50
Total: $50
A B C E F G H I $100! J K L M N O D $50
Total: $150
A B C E F G H I $100! J K L M N O D $50
Total: $150
A B C E F G H I $100! J K L M N O D $50
Total: $150
A B C E F G H I $100! J K L M N O D $50
Total: $150
this.hasLeftDoor() / this.hasRightDoor()
the cashFound variable.
Done? Check in on PollEverywhere pollev.com/comp110
your Documents folder (supposing there are subfolders). Same idea!
sites, programming language compilers, scene graphs)
complex relationships between objects
real-world concepts
types