.
Philhour
"The
art of teaching is the art of assisting discovery." - Mark Van Doren
2009-10 AP Computer Science - First Semester Course Weblog
Most recent update:
November 20, 2009 1:12 PM
Computer science is the study of information processing and algorithm design in the context of computer programming. In this course, students learn to write programs in the Java programming language then use Java to solve a variety of computational problems with algorithms of their own design. Units of study include program design, control structures, data structures, object-oriented programming, inheritance, abstraction, collections, recursion, and standard algorithms. Projects vary each year but may include text-based and graphics-based game programming, interactive web development, and database design and maintenance. Students are required to take the Advanced Placement test AP Computer Science A administered in May.
- Week of Friday, August 28 -- INTRODUCTION
- Day 1 - Activity Schedule
- Go over syllabus
- Computer resources
- Homework parties Wednesdays after school in Beta Lab
- Exams -- note that exams in this class are pencil & paper. This might seem strange, but will make more sense later. The AP exam itself is all pencil and paper -- no computers
- Lecture
- binary notation
- 8-bit and 16-bit conversions
- hexadecimal numbers
- storage of information in digital form -- loss of information & consequences
- practice problems
- HW
- Week of Monday, August 31 - First Java Programs
- Day 1
- Warmup: Convert some numbers from one base to another (instructor will supply)
- Recap binary & work problems with hexadecimal numbers (Q&A)
- Lecture
- storage of analog information in digital form -- loss of information & consequences
- generic data storage
- image storage
- 8 bits for each of RGB (so 24 bits total, or 16,777,216 possible colors)

- 250 pixels x 250 pixels = 62,500 pixels
- Compression! - basic idea is that it is sometimes cheaper (in terms of space) to describe a data set than it is to actually write out the data set. So, for instance, it takes less memory to write ("There will now follow 500 black pixels") than it is to write the color black (0,0,0) 500 times in a row.
- HW
- Problem Set 1 due Day 4
- Please make a Google account (we will be using shared documents from time to time)
- Day 2
- Recap & extend storage ideas
- audio storage
- Why we sample at at least twice the highest audible frequency (Nyquist sampling theorem)
- Example: stereo at 44 kHz with 16-bit precision, 2 channels (stereo) for one hour should produce 633 Mb, the capacity of a standard CD
- What is compression and why do we use it?
- video storage
- 1280 x 768 pixels = 983,040 pixels
- Usually need frame rates of 16 to 24 frames per second
- Practice problems
- Suppose you are measuring the temperature in Fahrenheit of your apartment and storing the values to disk
- How many bits of precision do you think you need?
- How often should you sample the data?
- How much data are you going to produce in one day? Is this a lot?
- High speed HDTVs now boast 1920 x 1080 pixels (1080i) and refresh rates of 60 Hz -- how much space would be required to store 2 hours of material for an HDTV without any compression?
- Lecture
- We store data AND commands as binary numbers
- The basic components of computer programming (please put these to memory)
- assignment of information to and from computer memory ("store this number X at memory location Y so I can use it later")
- input and output to a user (keyboard, mouse, monitor, printer, ...)
- looping ("repeat the following instructions many times)
- conditional branching ("if this is true, do this; otherwise, do something else")
- simple logic evaluations ("if this OR this is true, do this; ... if this AND this are true, do this ...")
- subroutines, abstraction, and encapsulation ("certain things my program does over and over again should be separate from the rest of the program so I can refer to it many times"
- HW
- Day 3
- Day 4
- Warmup: practice writing and compiling a "Hello World" program from scratch.
- Tutorial
- The Scanner class - communicating with the user or with files.
- Making Scanner objects
- Scanner reader;
- reader = new Scanner(System.in);
- using Scanner objects to read in information from the user
- int y = reader.nextInt();
- double x = reader.nextDouble();
- String s = reader.nextLine();
- making a simple math quiz program
- making Random primitives to really enhance the math quiz program
- Random gen
- gen = new Random();
- int y = gen.nextInt(10); // generates random number from 0 to 9
- using comments with the // and /* */ symbols
- HW
- Week of Monday, September 7
- Monday
- Day 1 - Activity Schedule
- Warmup: try to write, compile, and run MathQuiz.java from SCRATCH, without reference to the file above. If you get stuck, talk to a friend. Only look at the file in the public folder (see below) as a last resort. We need to build up some memory through repetition and this is a good way to do it. Do your best.
- IMPORTANT NOTE: I'll be copying & pasting in-class programs to the PUBLIC FOLDER. So the work we did on Friday was MathQuiz.java, and this can be found in the public folders in your e-mail. Go to Public Folders then go to Course Discussion then go to Technology Education and AP Computer Science. It should be there.
- Primitive types!
- int
- use 4 bytes (32 bits) of information to store; one bit is used to distinguish between positive and negative numbers, leaving 31 bits to store the number's value itself. The range is -2,147,483,648 to +2,147,483,647. They must be whole numbers.
- double
- use 8 bytes (64 bits) of information to store; one bit is used to distinguish sign (as with integers) but the decimal point is allowed to "float" meaning that the precision (number of significant digits) is fixed but the value can grow quite large. The range is about -1.79x10^308 to 1.79x10^308. It is very important to recognize that a computer does not have the memory range to store the INFINITE number of numbers that actually exist in nature. So doubles aren't "really" infinitely precise, just more precise than ints.
- char
- The char data type is used for single characters and escape functions -- we won't often be using the char data type in this class
- Time permitting: introduction to looping -- using the WHILE loop and the BREAK command.
- Repetition is one of the main reasons we use computers to do stuff.
- We'll write a program that adds up all the numbers from 1 to N, where N is provided by the user.
- HW
- Day 2 - Activity Schedule
- The basic components of computer programming (please put these to memory)
- assignment of information to and from computer memory ("store this number X at memory location Y so I can use it later") we've been doing this when declaring (int x) and initializing (x = 5) variables!!!
- input and output to a user (keyboard, mouse, monitor, printer, ...) we've been doing this using the Scanner class and the System.out.println() method
- looping ("repeat the following instructions many times) we're just starting this
- conditional branching ("if this is true, do this; otherwise, do something else") we used the IF statement and the ELSE statements for this
- simple logic evaluations ("if this OR this is true, do this; ... if this AND this are true, do this ...") we will learn this a bit later
- subroutines, abstraction, and encapsulation ("certain things my program does over and over again should be separate from the rest of the program so I can refer to it many times") -- we'll begin this a bit later
- Looping continued
- WHILE loops and the BREAK command -- combining these with conditionals
- If we didn't get there yesterday: we'll write a program that adds up all the numbers from 1 to N, where N is provided by the user.
- HW
- Continue working Problem Set 2 (due Day 3)
- Prepare for Quiz on Day 3
- Day 3 - Activity Schedule
- QUIZ 1.1 ON MATERIAL OF CHAPTERS 1 & 2 (all material so far from lecture as well)
- HW
- Begin Problem Set 3
- NOTE: Please begin bringing your textbook to school every day; I will ask you to use it extensively once the baby comes
- Thursday Night
- Parents Back to School Night
- Friday
- Week of Monday, September 14
- Day 1
- NOTE: Please begin bringing your textbook to school every day; I will ask you to use it extensively once the baby comes
- Note: if you received a quiz score of 4.0, no need to turn in corrections (it's automatic). If you received a score above 3.0, turn in corrections written directly on the test itself; if you received a score beneath 3.0, please write up corrections on a separate piece of paper and staple to the original. Corrections are due at the next class meeting.
- Warmup: programming practice - write a program that asks the user for a number from 1 to 9, then prints out all the multiples of that number between 1 and 100 (so, for instance, if they type in '7' it will print out 7, 14, 21, 28, ... until the number exceeds 100)
- Note: I only graded the 2nd part of the first quiz if your score was higher than on the 1st part. We will have memorization-of-code parts routinely, but we're obviously not quite there yet.
- Using math in Java
- The Math class and some of the useful operations it can perform
- no need to import Math -- automatically in there as part of the language
- Double d; int x;
- Math.sqrt(); // square root
- Math.abs(); // absolute value
- Math.pow(base, exponent); // powers
- Math.round(); // rounds to nearest whole number (still a double!)
- Math.max(a, b); // finds the greater of a and b
- Math.min(a, b); // finds the lesser of a and b
- The modulus operator % -- how to find remainders when integers are divided
- Note that 7%2 = 1, so 7 must be odd; 6%2 = 0, so 6 must be even -- you can tell if something is odd or even by determining whether it gives a remainder upon division by 2
- Order of operations -- this is very similar to what you're used to in math, so just read the textbook for this part in Ch 3
- Some of the tricks of integer math
- HW
- Day 2
- NOTE: Please begin bringing your textbook to school every day; I will ask you to use it extensively once the baby comes
- Warmup: programming practice - write a program that asks the user to enter a number and then determines whether that number is prime. The way to determine if a number N-1 is prime is to try every number between 2 and N/2 and see if it divides evenly into N (leaving no REMAINDER -- think mod %)
- Brief lecture: Method encapsulation - how to hide parts of your program -- this is one of those "BIG IDEAS" in programming
- HW
- Day 3
- Warmup: programming practice - write a program that creates a random number between 1 and 100, then asks the user to guess it. After each guess, the computer either says "YOU GOT IT!" and ends the program or says "Higher" or "Lower" (Hint: use the Math.max() or Math.min() methods) and asks the user to guess again. (Hint again: use an infinite while() loop and only break if they get the answer)
- Mini-Lecture: multi-mode arithmetic & casting
- Mini-Lecture: errors -- division by integer zero, null pointer exception (lack of initialization), no such method error
- HW
- Day 4
- Warmup: programming practice - write a simple math program OF YOUR DESIGN using the material of this week
- Lecture: using the escape characters \n, \t, and \\
- HW
- Continue Problem Set 3 - due Day 3 of next week (NOTE CHANGE IN DUE DATE)
- Week of Monday, September 21
- Day 1
- Note: if you received a quiz score of 4.0, no need to turn in corrections (it's automatic). If you received a score above 3.0, turn in corrections written directly on the test itself; if you received a score beneath 3.0, please write up corrections on a separate piece of paper and staple to the original. Corrections are due at the next class meeting after you get the thing back.
- Continue & finish up programming projects with Albert Boyle
- HW
- Day 2
- Catch up on mini-lectures from last week as needed
- Using math in Java
- The Math class and some of the useful operations it can perform
- no need to import Math -- automatically in there as part of the language
- Double d; int x;
- Math.sqrt(); // square root
- Math.abs(); // absolute value
- Math.pow(base, exponent); // powers
- Math.round(); // rounds to nearest whole number (still a double!)
- Math.max(a, b); // finds the greater of a and b
- Math.min(a, b); // finds the lesser of a and b
- The modulus operator % -- how to find remainders when integers are divided
- Note that 7%2 = 1, so 7 must be odd; 6%2 = 0, so 6 must be even -- you can tell if something is odd or even by determining whether it gives a remainder upon division by 2
- Order of operations -- this is very similar to what you're used to in math, so just read the textbook for this part in Ch 3
- Some of the tricks of integer math
- Mini-Lecture: multi-mode arithmetic & casting
- Project: write a program that (soft version) determines if a user-entered number is ODD or EVEN or (hard version) determines if a user-entered number is PRIME
- HW
- Day 3
- Warmup: continue work on the prime number program from Day 2
- Tutorial
- String objects and methods (y.length())
- reader.nextLine() using the Scanner class
- Programming project: write a short program that asks for the users name and then tells them how many letters there are in it
- In-class: continue Problem Set 3 - due Day 1 of next week
- HW
- Day 4
- Warmup: continue work on the name-length program from Day 3
- Tutorial
- Using the escape characters \n, \t, and \\
- In-class: continue Problem Set 3 - due Day 1 of next week
- HW
- Continue Problem Set 3 - due Day 1 of next week
- If you're getting ahead -- you can begin Problem Set 4
- Prepare for Quiz (Step 2) on material of Ch 2 & Ch 3 on Day 1
- Yes, you will be asked to write a program from memory
- Week of Monday, September 28
- Day 1
- Turn in Problem Set 3
- Quiz 1.2 on material of Ch 2 & Ch 3 (including a part where you write a program from memory)
- HW
- Day 2
- Warmup: Make an account at JavaBat
- I will walk you through the JavaBat exercise sleepIn
- The difference between writing a class (like we have been), writing a main method (like we have been) and writing a regular old method (like we need to do in JavaBat)
- parameters to a method -- the 'inputs'
- products of a method -- the 'outputs'
- using a return statement to return the result of a method (to 'output')
- Work the JavaBat exercise nearHundred -- note that this returns a BOOLEAN as output, not an integer
- We're going to do a lot of exercises in JavaBat as warmups this term, so don't do too many on your own outside of class =)
- Tutorial: Using +=, -+, ++, --, *=, /=, %= and += with concatenation as a time-saving device
- Continue Problem Set 4
- HW
- Day 3
- Warmup: JavaBat icyHot
- Tutorial: when you need to add code braces { } after a while or if-else statement, and when you don't have to do that
- Continue Problem Set 4
- HW
- Day 4
- Quiz 2.1 on material of Ch 4 UP TO and including Ch 4.5 -- mostly on if and if-else statements and while statements
- Continue Problem Set 4
- HW
- Week of Monday, October 5
- Day 1
- Warmup: JavaBat loneTeen
- Tutorial: using the for statement instead of the while statement. A little 'cleaner' but more complicated at first.
- Continue Problem Set 4
- HW
- Day 2
- Warmup: JavaBat monkeyTrouble
- Nested Control Statements
- Making 'pyramids' of numbers using these
- HW
- Day 3
- Warmup: JavaBat parrotTrouble
- File objects - create with a String as a parameter, and this String should have the file name
- the main method needs to throws IOException
- be sure to import java.io.*
- Using Scanner with files instead of with Keyboard input
- using reader.hasNext() to check if there are still lines in the file being read
- Using PrintWriters to make files
- be sure to writer.close() when finished!
- HW
- Day 4
- Quiz 2.2 on material of Ch 4 (including a part where you write a program from memory)
- HW
- Prepare for Midterm Exam on Monday -- this will be a 'Step 3' exam covering the material of all quizzes so far, and including all the material in Chapters 1 - 4. There will be a portion of the exam that includes memorization, as you've seen in class. This midterm exam will constitute a Step 3 exam for BOTH of Units 1 and 2 (see gradebook) -- Unit 1 covers Chapters 1 - 3, Unit 2 begins with Chapter 4.
- Week of Monday, October 12
- Monday
- MIDTERM EXAM (see notes above under Day 4) - Step 3 in Units 1 and 2
- HW
- We'll go back and do some of the GUI material in Chapters 1 - 4, so we're NOT YET moving on to Ch 5.
- Begin Problem Set GUI A
- Note that for all GUI material, you'll have access to this GUI A Cribsheet (for instance, on quizzes and exams) so please make it your friend =)
- Tuesday
- Wednesday
- No class, PSAT & Freshman Retreat
- Thursday
- No class, Teacher Inservice
- Friday
- Week of Monday, October 19
- Day 1
- JavaBat: cigarParty
- GUI Material -- the basics
- Making a basic empty frame
- Getting the content pane and adding JPanels
- Programming project: making a random color JPanel appear in a frame each time you run the program!
- Note that for all GUI material, you'll have access to this GUI A Cribsheet (for instance, on quizzes and exams) so please make it your friend =)
- Day 2
- JavaBat: dateFashion
- Layout managers -- using BorderLayout & GridLayout (see public folder for detailed programs)
- Day 3
- JavaBat: squirrelPlay
- Tutorial on GUI Material of Chapter 3
- Making your own extensions of the JPanel class (we're calling these ColorPanel but we could really call them anything we wanted)
- The graphics context / overwriting the paintComponent method
- g.setColor()
- g.drawRect()
- g.drawOval()
- g.drawString()
- When in a panel we can use
- HW
- Continue Problem Set GUI A - finish the Chapter 2 material by the Quiz on Day 4
- Prepare for Quiz on Day 4
- Day 4
- Quiz on GUI Material so far
- Continue Problem Set GUI A -- work on material of Chapter 3
- HW
- Week of Monday, October 26
- Day 1
- JavaBat: alarmClock
- Note: I made an error in including Chapter 3 material on last week's quiz. Sorry about that, just a mind-slip. I gave you a grade based on the Chapter 2 grade UNLESS the Chapter 3 material helped, in which case I gave you that grade.
- Continue Problem Set GUI A -- work on material of Chapter 3
- If finished on this Chapter 3 material, write a program that makes a themed (unifying colors/shapes) but random aesthetic piece. Share a screenshot with me by e-mail so I can decorate this couse weblog with them.
- HW
- Day 2
- Day 3
- Day 4
- Exam on GUI Material so far
- HW
- Week of Monday, November 2
- Day 1
- Warmup: makeBricks
- Tutorial on String methods needed for Javabat warmups of the next few weeks
- Hand out crib sheet for Strings / Java
- Introduction to material of Chapter 5 (classes & object-oriented programming!)
- Big Ideas - how methods communicate through classes
- Important note: the material from today on Strings will be 'part of Ch 5' in terms of quizzes & exams
- Continue Problem Set 5A
- HW:
- Day 2
- Day 3
- Day 4

- Warmup: JavaBat endOther
- Writing the Who and Whoville classes
- accessor ("getter") methods
- mutator ("setter") methods
- helper methods of various kinds
- visibility modifiers (public, private)
- constructor methods
- toString() methods
- scope of variables
- TESTER programs
- Continue Problem Set 5A
- HW:
- Week of Monday, November 9
- Day 1
- Warmup: JavaBat countTriple
- More adventures in Who-ville
- Producing children
- Formal and informal parameters
- Communicating via methods
- Constructors -- why they are different
- Multiple constructors
- Type in, execute, and play around with material in practice Quiz 5 (Ch 5) (pdf, doc, key in pdf, key in doc)
- HW:
- Day 2
- Quiz on material of Chapter 5 so far (problem set 5A stuff)
- HW:
- Day 3
- JavaBat: repeatSeparator
- Review classes & methods
- the Fraction class from the most recent homework assignment
- Using Eclipse as an Integrated Development Environment (IDE)
- Reworking some old problems in Eclipse to make sure everything still works and we understand what we're doing:
- Enter in the Planet & Star classes from the quiz key from this week and try out the tester program in Eclipse.
- Make a pop-window that displays a circle, a square, and a triangle in an aesthetically pleasing combination
- Write a program that asks the user for his or her full name (first and last) and outputs them as separate strings (that is, it finds the space using a loop and then produces two substrings for first and last names) (this is called parsing)
- HW:
- Day 4
- JavaBat: getSandwich
- Using Eclipse
to do a FUN PROJECT
- Design & write your own set of classes to do something useful. We'll work in groups of 3. You should produce THREE classes: one is a 'tester' class with a main method, the other two help out (like Star & Planet, or like Actor & Show, or ...)
- The tester class should involve SOME user IO.
- Use this to sort out issues. Be creative. Post all three classes to the public folder in a SINGLE post by the end of the period.
- HW:
- Continue Problem Set 5B due Day 1 of next week
- Download & install Eclipse on your home computer
- Prepare for Quiz on Day 1 of next week
- Week of Monday, November 16
- Day 1
- Problem Set 5B due
- Quiz on material of Chapter 5 (not including GUI stuff -- just stuff from problem sets 5A and 5B)
- HW
- Day 2
- Warmup: javaBat catDog
Daine's Psychology Application -- check it out (Java .jar file - you can export these from Eclipse and share your programs with anybody who can run Java on their computers (most everybody))
- Tutorial: Loading & displaying images in a JPanel
- Continue Problem Set GUI-B in class
- HW
- Day 3
- Warmup: javaBat zipZap
- Tutorial: Implementing the Circle class
- Here's the new GUI Cribsheet (.doc, .pdf) which includes material from Chapter 5
- Continue Problem Set GUI-B in class
- HW
- Day 4

- Week of Monday, November 23
- Day 1
- Warmup: javaBat plusOut
- Review Classes Material from Chapter 5 -- wrap up GUI-B material as needed
- How to declare & instantiate objects
- How to call methods on objects
- How to write classes
- How to communicate between classes through methods
- Time-permitting: Programming project - brainstorming
- HW
- Continue Problem Set GUI-B due Day 2
- Your exam tomorrow (Ch 5) will be slightly different format than we've grown accustomed to: there will be more short-answer questions
- Day 2
- Exam on material of Chapter 5 (NOT including GUI stuff)
- This is the first of two Step 3 exams
- HW
- None -- enjoy your thanksgiving!
- Wednesday
- Thursday
- Holiday - Happy Thanksgiving!
- Friday
- Week of Monday, November 30
- Day 1
- Warmup: javaBat sameStarChar
- Practice with material of Chapters 1 - 5
- Programming project - brainstorming
- Project rubric (.pdf, .doc) - grade will go into both OOP & GUI units at Step 3
- Project proposal due Day 3
- Must make use of Classes, Arrays, and GUI -- more info to come (but, for instance, you could make an array that allows you to control a number of Circle objects with the mouse)
- HW
- Continue programming project proposal - due Day 3
- Reading material on Arrays (TBA)
- Day 2
- Warmup: javaBat xyzThere
- Introduction to Arrays
- Programming project - brainstorming
- Project rubric (.pdf, .doc) - grade will go into both OOP & GUI units at Step 3
- Project proposal due Day 3
- HW
- Continue programming project proposal - due Day 3
- Reading material on Arrays (TBA)
- Day 3
- Warmup: javaBat middleWay
- Array review
- Arrays and loops
- HW
- Prepare for Quiz on Day 4 (GUI-B material)
- Work on programming project
- Day 4
- Quiz on material of GUI-B (Chapter 5 but also any previous stuff)
- Here's the new GUI Cribsheet (.doc, .pdf) which includes material from Chapter 5
- HW
- Work on programming project
- Week of Monday, December 7
- Day 1
- Day 2
- Day 3
- Day 4
- Exam on material of Chapter 5 (including GUI stuff)
- This is the second of two Step 3 exams
- HW
- Week of Monday, December 14 -- FINAL EXAMS
- Monday - Activity Schedule
- TBA
Spring 2010