AP computer Science A
Java Methods, Third AP* Edition
Be sure to download from there: Student files ; Slides
All classroom material is distributed through
You need a github account for this.
We program together in class, and then links are given to students for the classroom assignment.
We often also code together in class CodingBat and PrcticeIt problems (and rarely hackerrank).
You will also open an account on CodingBat and PracticeIt.
On CodingBat, add me as your teacher (see profile settings).
Intro and setup.
Topics: Setup the environment: JDK, IDE, Editor, Github.
This one does it all:
Just if you need: JDK: Oracle JavaSE IDE - NetBeans: https://netbeans.org/
Editors: Atom [ https://atom.io/] or Sublime [ https://www.sublimetext.com/]
Netbeans and Git (Clone) ; https://github.com/
Resources for the Java Methods book:
Student files ; Slides
In class activity: Syllabus. AP. Game of Nim (intro to algorithms). Installation.
Topics: Command line, IDE, graphics, and GitHub classroom setup.
Code: "Hello World" Command line [
QQQgithub] - Javac, java.
Code: "Hello World"" IDE [
QQQgithub] - Working with the IDE.
Code: "Hello World" Graphics [
QQQgithub] - Intro to graphics.
Code: "Hello World" Github [
QQQgithub] - Working with IDE and github. Homework: First homework on Github Classroom.
Code: KPoint [
github] - Introduction to class, fields, methods, constructors. Homework: Add functionality to the point class.
Primitive types + Strings
Topics: Primitive types: Char, int, double, boolean.
Topics: Strings: Objects, length, substring, charAt, indexOf, compareTo, equals.
Drill: Codingbat- Warmup, String-1, no loops.
Code: KString [
github] - Our own String class. Homework: Hyphen2(), isPalindrome().
Code: TempConverter [
github] - Homework: Simple integer arithmetic.
Code: BaseConverter [
github] - Converting between Dec, Binary, Octal, and Hex. Homework: Complete the class.
Boolean + if()
Topics: Boolean, logical operators: Simple. De Morgan's law.
Drill: Codingbat- logic-1. Warmup
Logic, not programming. Nice one to start!
Logic, little harder than 1.
If/then/else: Do this one together in class, to see good programming style.
A little harder ones:
if/else with integer division. No program, just MC.
if/else Days in month:
While() and for() loops
github] - Loops and strings. Homework: Complete the game.
Codingbat- String-2, including loops.
ZipZap. (not easy!)
xyBalance.Seems complicated, but has a VERY neat solution.
Nested for() loops
Triangles and pyramids [
github] - Nested loops for printing ASCII art. Homework: Complete shapes.
Langauge feature: break and continue.
Prime: isPrime(), allPrimesUpTo(), firstNPrimes() [
Codingbat- String-3, nested loops. Well, you might use. Don't have to.
Paying attention to 'first time right' (or minimum times wrong). Then, paying attention to reduced code!
countTriple Simple one to start with.
gHappy - Logic makes it simple.
maxBlock - Not really complicated. Think simple.
withoutString - Two hints:
Use str.toLowerCase() when comparing.
Substitute from the ORIGINAL string (not from lowercase). Like the Hangman.
Codingbat- String-3, nested loops. Two problems I wrote to demeonstrate use of While() and use of tmp.
switchXwithNext - use of tmp.
stringCombine - multiple indexes.
Write your own CodingBat problems! Here is what the students came up with (very original!!):
Basic 1D array cnocepts and operations : [
1D Array: CodingBat - Array-1 (no loops)
1D Array: CodingBat - Array-2 (loops)
centeredAverage. We'll do this one together as well.
1D Array: CodingBat - Array-2 (loops) and Array-3 (Nested or multiple loops)
twoTwo - Keep it simple: We have seen the pattern.
zeroFront - Special interest: Continue/break.
evenOdd - Indices. one loop.
canBalance - Simple loops. Logic.
squareUp - Indices. Nested loop. simple logic.
Random: java.util.Random and Math.random.
Command line arguments. Homework: 1D array shuffle [
(We did not do this year) Homework: Fibonnaci class (return array, return element, return next element) [
Magic square [
Homework: Haiku (2D array decoding) [
Some more workouts on Arrays - CodingBat.
1D to 2D array of ints. (zz530_1dTo2DInts).
Array of Strings. (zz520_longestString).
Bubble sort: Wrapping up 1D array, and talking about sorting (time, space) [
PracticeIt: Mystery array.
2D ascii art.
Some fun with arrays and strings:
scoresSpecial: Helper function
mergeTwo : Strings and arrays
OOP:: Methods, Class
Primes example in class [
Euler problems homework:
Euler7 - 10,001 prime. We'll do together in class
Euler9 - Pythagorean triplet
Euler39 - Integer right triangle
Euler46 - Goldbach's other conjecture. BTW, his other conjecture: Every even integer greater than 2 can be expressed as the sum of two primes. I would recommend the book "Uncle Petros and Goldbach's Conjecture")
Bank account example: Inheritance, Encapsulation, 'extends', this, super (dot notation, constructor), constructor. Overloading methods toString, static/class variable. Array of objects, casting. Which function is called? determined by the OBJECT
Interfaces and Abstract classes:
Implements keyword, Abstract keyword
Interface - Contract ; Abstract -
Examples we used:
Inheritance: Simple BankAccount:
Abstract class: Animal:
Interface class: Costable:
Mobile example, interface -
Mobile Shape example, abstract
Shape [HW] Animal
Comparable interface :
Recursion: Factorial, Towers of Hanoi, palindrome.
[ github files].
Search and Sort
Search: Sequential, binary. 
Sort: Bubble, Selection, Insertion, Merge. [
Conway game of life: Logic
Battle Ship: AI [
FR_2013_4_2DArray: Skyview, raster scan. (medium)
FR_2012_4_2DImage: Simple 2D array processing. (easy)
FR_2017_3_String: String operation. (medium)
The whole material
^ Password protected.
Questions/Comments: Zbaharav at Kehillah dot Org or Zachi at Baharav dot Org .