AP computer Science A


Older Syllabus_2016_AP_CS_Baharav_Block_2.pdf



Java Methods, Third AP* Edition
Be sure to download from there: Student files ; Slides


Practice online:


Learn online:



Course outline:

  1. Intro and setup.
    1. Topics: Setup the environment: JDK, IDE, Editor, Github.
      This one does it all: Installation_NetBeans_JDK_Eclipse.pdf
      Just if you need: JDK: Oracle JavaSE IDE - NetBeans: https://netbeans.org/ Screen-shot
      Editors: Atom [https://atom.io/] or Sublime [https://www.sublimetext.com/]
      Netbeans and Git (Clone) ; https://github.com/
    2. Resources for the Java Methods book: Student files ; Slides
    3. In class activity: Syllabus. AP. Game of Nim (intro to algorithms). Installation.
  2. "Hello World"
    1. Topics: Command line, IDE, graphics, and GitHub classroom setup.
    2. Code: "Hello World" Command line [QQQgithub] - Javac, java.
    3. Code: "Hello World"" IDE [QQQgithub] - Working with the IDE.
    4. Code: "Hello World" Graphics [QQQgithub] - Intro to graphics.
    5. Code: "Hello World" Github [QQQgithub] - Working with IDE and github. Homework: First homework on Github Classroom.
    6. Code: KPoint [github] - Introduction to class, fields, methods, constructors. Homework: Add functionality to the point class.
  3. Primitive types + Strings
    1. Topics: Primitive types: Char, int, double, boolean.
    2. Topics: Strings: Objects, length, substring, charAt, indexOf, compareTo, equals.
    3. Drill: Codingbat- Warmup, String-1, no loops.
      1. HelloName
      2. FirstHalf
      3. MissingChar.
      4. HasBad.
      5. sleepIn
    4. Code: KString [github] - Our own String class. Homework: Hyphen2(), isPalindrome().
    5. Code: TempConverter [github] - Homework: Simple integer arithmetic.
    6. Code: BaseConverter [github] - Converting between Dec, Binary, Octal, and Hex. Homework: Complete the class.
  4. Boolean + if()
    1. Topics: Boolean, logical operators: Simple. De Morgan's law.
    2. Topics: if().
    3. Drill: Codingbat- logic-1. Warmup
      1. QQQQ
    4. Drill: PracticeIt-
      1. Logic, not programming. Nice one to start! ifElseMystery1
      2. Logic, little harder than 1. ifElseMystery2
      3. Nice Programming quadrant
      4. If/then/else: Do this one together in class, to see good programming style. Coordinates
      5. A little harder ones:
      6. if/else with integer division. No program, just MC. ifElseSimulation
      7. if/else Days in month: daysOfMonth
      8. if/else Tax: Tax
  5. While() and for() loops
    1. Hangman [github] - Loops and strings. Homework: Complete the game.
    2. for()
    3. Codingbat- String-2, including loops.
      1. doubleChar
      2. Bob there.
      3. ZipZap. (not easy!)
      4. xyBalance.Seems complicated, but has a VERY neat solution.
    4. Nested for() loops
    5. Triangles and pyramids [github] - Nested loops for printing ASCII art. Homework: Complete shapes.
    6. Langauge feature: break and continue.
    7. Prime: isPrime(), allPrimesUpTo(), firstNPrimes() [ github]
    8. 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!
      1. countTriple Simple one to start with.
      2. gHappy - Logic makes it simple.
      3. sameEnds
      4. maxBlock - Not really complicated. Think simple.
      5. withoutString - Two hints:
        1. Use str.toLowerCase() when comparing.
        2. Substitute from the ORIGINAL string (not from lowercase). Like the Hangman.
    9. Codingbat- String-3, nested loops. Two problems I wrote to demeonstrate use of While() and use of tmp.
      1. switchXwithNext - use of tmp.
      2. stringCombine - multiple indexes.
      3. Write your own CodingBat problems! Here is what the students came up with (very original!!):
  6. Arrays
    1. 1D Array
      1. Basic 1D array cnocepts and operations : [github]
        1. 1D Array: CodingBat - Array-1 (no loops)
          1. firstLast6
          2. no23
          3. sum3
          4. makeLast
          5. plusTwo
          6. frontPiece
        2. 1D Array: CodingBat - Array-2 (loops)
          1. countEvens
          2. shiftLeft. Interesting.
          3. sum67
          4. centeredAverage. We'll do this one together as well.
        3. 1D Array: CodingBat - Array-2 (loops) and Array-3 (Nested or multiple loops)
          1. twoTwo - Keep it simple: We have seen the pattern.
          2. zeroFront - Special interest: Continue/break.
          3. evenOdd - Indices. one loop.
          4. Array-3
          5. canBalance - Simple loops. Logic.
          6. squareUp - Indices. Nested loop. simple logic.
        4. PracticeIt warmups:
          1. arrayMystey-final1
          2. arrayMystey-final2
      2. Random: java.util.Random and Math.random.
        Command line arguments.
        Homework: 1D array shuffle [ github].
      3. (We did not do this year) Homework: Fibonnaci class (return array, return element, return next element) [ github].
    2. 2D Array
      1. Magic square [github].
      2. Homework: Haiku (2D array decoding) [github].
    3. Some more workouts on Arrays - CodingBat.
      1. 0-block: 1D to 2D array of ints. (zz530_1dTo2DInts).
      2. Blitz:
        1. commonEnd
        2. maxEnd3
        3. double23
      3. HW:
        1. Array of Strings. (zz520_longestString).
        2. countClumps (medium/hard)
        3. fix34 (challenging)
        4. Mirror (hard)
    4. Bubble sort: Wrapping up 1D array, and talking about sorting (time, space) [ github].
    5. 0-block:
      1. PracticeIt: Mystery array. sum/difference
      2. 2D ascii art.
    6. Some fun with arrays and strings:
      1. wordsCount
      2. scoresSpecial: Helper function
      3. mergeTwo : Strings and arrays
  7. OOP:: Methods, Class
    1. Primes example in class [ github].
    2. static/class variable/method
    3. Euler problems homework:
      1. Euler7 - 10,001 prime. We'll do together in class
      2. Euler9 - Pythagorean triplet
      3. Euler39 - Integer right triangle
      4. 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")
  8. OOP:: Inheritance:
    1. Basic concepts:
      1. 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 itself. BankAccount
      2. [HW] Person Person Github
    2. Interfaces and Abstract classes:
      1. Implements keyword, Abstract keyword
      2. Interface - Contract ; Abstract -
      3. Examples we used:
        1. Inheritance: Simple BankAccount: Inheritance BankAccount
        2. Abstract class: Animal: Abstract Animal
        3. Interface class: Costable: Interface Costable
      4. Mobile example, interface - Mobile
      5. Shape example, abstract Shape
      6. [HW] Animal
      7. PracticeIt:
      8. Comparable interface : Git
  9. ArrayList
    1. ArrayList shuffle: [github files].
    2. ArrayList Josephus: [github files].
    3. ArrayList AlwaysSorted: [github files].
  10. Recursion: Factorial, Towers of Hanoi, palindrome. [github files].
  11. Search and Sort
    1. Search: Sequential, binary. []github files].
    2. Sort: Bubble, Selection, Insertion, Merge. [github files].
  12. Larger projects:
    1. Conway game of life: Logic [github files].
    2. Battle Ship: AI [ github].
  13. Practicing: AP-FR
    1. FR_2013_4_2DArray: Skyview, raster scan. (medium)
    2. FR_2012_4_2DImage: Simple 2D array processing. (easy)
    3. FR_2017_3_String: String operation. (medium)
  14. The whole material



^ Password protected.


Questions/Comments: Zbaharav at Kehillah dot Org or Zachi at Baharav dot Org .