AP Computer Science assignments

Mr. Joo

2010-2011



? - article: Bill and Paul
Just read a little minor news about Bill and Paul that came out last week:
http://www.latimes.com/business/la-fi-0331-gates-allen-20110330,0,2541965.story



6/1 - final project
Drop final projects here, by the end of the school day 6/6.

The presentation doesn't have to be much.  Just show off your program, maybe some of your code, talk about what was interesting/challenging/cool/whatever, for 2-5 minutes.  If you want to make a couple slides to highlight some things or some code, that's fine. 

As for your code, if you're submitting, for example, 26 classes that your copied/modified from GridWorld, don't expect me to read through all that code to find the 17 lines that you actually changed.  I ain't doing that.  Only include code you modified.  Just import the stuff you copied wholesale.  And if you have 20 classes where you just changed a little bit, it'd be really great if you included a text document where you bold/highlight/color code the code that you did change, so that I know what to look at.

Documentation:  At the very least, instructions on how to run your program.  But the more you document the work that you've done, the easier you'll make it for me to give you points.

The project will be worth 200 points.

(5/25 - book return)

(5/1 - AP CS TEST makeup)

(5/1 - AP CS TEST)
AP Test - Computer Science
8am @ AHS cafeteria

5/4 - final project proposal
This is not to say that this is final and you're locked in.  If you decide you want to change course somewhat or even completely after this, that's up to you.  But by Monday, I need a piece of paper describing what you want to do for your final project and justifying why it will be four weeks worth of work and what you'll have to learn to pull it off.  Beyond that, it's up to you to decide how much detail you want to provide.  Layout of what classes/methods you might need?  Sketches of graphics?

A game?  A useful application?  An iPhone/smartphone app?  Learn a new language and do something in that?  Using an extension of GridWorld?  Something else entirely?  Whatever the case, you are *not* going to spend the next four weeks doing nothing in class and then frantically cram it out in the last two days.  Unless you don't care about passing the class.

Examples of GridWorld extensions:  http://www.apcomputerscience.com/gridworld/boardGames.htm

4/29 - final AP review
some good things for last minute review:
- the rest of the practice exam from Thursday's assignment, and review of your mistakes on the multiple choice
- the remaining Javabat AP-1 exercises
- review past FRQs, particularly GridWorld
- look over the GridWorld code, esp. Actor, Bug, and Critter, and learn where useful things are in the Quick Reference

4/22 - AP practice exam - FRQ 3 GW
From yesterday's practice exam, do FRQ #3, the GridWorld question.  Some time before next Tuesday (like over the weekend), you may want to do the rest of these practice FRQs, too.

4/28 - AP practice exam - multiple choice
This is the official practice exam.  (In other words, it wasn't ever actually administered as a real AP exam.)  For today, let's try the multiple choice. Get as far as you can in class, then finish it up, score it, and go over it for homework.
<A_PE_0708.pdf>

4/26 - Javabat AP-1 x 7
Let's do the following exercises in Javabat, AP-1:

 copyEvens
 dividesSelf (harder)
 matchUp (might use boolean short-circuiting)
 scores100
 scoreUp
 wordsCount
 wordsWithoutList

Most of you have done at least the two crossed out; some of you have done more. To make it an even seven, in addition to the five above, do two more AP-1's of your choice.

Let's say by end of period Friday, so you can have a little class time to get help/work together on anything you get stuck on.

- psychedelic gridworld screensaver
This sounds like a nice little diversion for the day:

- - - -

 Date: Fri, 20 Apr 2012  2:48 PM
 From: "Steve Gregg" <stevegregg@aol.com>
 Subject: Interesting Critter graphical effect
 As we were starting to learn how to write simple Critters, one of my students and I came up with this graphical effect.  If anyone turns this into a commercial screensaver and makes money off of it, please send us royalties :-)
 
  (1)  Write a RockDropper critter that behaves just like a Critter, except that, after it moves, it drops a Rock of its same Color into the square it just vacated.  Do this by overriding the makeMove method.  Also, write a RockCritter constructor which allows you to specify the color of the Critter when it is first created.
 
  (2)  Write a RockEater critter which, when it makes its move, will always "teleport" to a randomly chosen square in the grid which is occupied by a Rock.  Do this by overriding the getMoveLocations method, so that the ArrayList it returns consists of all the Locations in the grid that contain Rocks.
 
  (3)  Finally, in the driver, create a reasonably large grid (mine was 40 by 70), and place in it three or four RockDroppers of different colors, and a single RockEater.  Then put the GUI on full speed, and watch it run!  I was mesmerized by this effect, since the RockDroppers, left to their own devices, soon get stuck amongst the Rocks they have dropped, but then they eventually escape to move again, due to the RockEater clearing out an escape route.
 
  Steve Gregg
  Head-Royce School

4/21 - frq2010-4
warmups:  Javabat AP-1 dividesSelf (harder)

main event:  2010 FRQs.
 This is last year's AP test.  Some of the easiest questions ever seen on an AP CS test.  Normally, a really easy question has a mean score in the low 5s.  On many tests, there aren't any questions in the 5s. Mean scores for this test:
  Q1 5.46
  Q2 6.34
  Q3 5.84
  Q4 3.64
 Yes, that's right. Only one question *below* 5. And there's even a 6!!!  I've never seen a 6 before.

More interestingly, usually, the GridWorld question is one of the easier questions, but on this test, the GW question was the one hard question.  So guess which one your assignment is.  Yep, try your best on the GW question.  Take three passes through it, in 3 different colors:
 1) in pencil, 26 minutes, like a real test
 2) in pen, untimed, using whatever resources you need, answer it as best you can, then
 3) correct in using the solution.

(You might also want to try the super-easy question, #2, just for giggles.)
<ap10_frq_computer_science_a.pdf>
<ap10_scoring_guidelines.pdf>

- frq2011-4
Question 4 from last year's AP test.  Mean score was 3.53, making it somewhat difficult, but not the hardest question on the test.

- grid tac toe
Try using GridWorld to make a graphical tic tac toe game.

4/19 - frq2008-1 and 2008-2
2 questions, 52.5 minutes.
We've done 3 4, so here are 1 2 from 2008.  Mean scores were 4.74 and 3.36, respectively.
- - - -
You don't need to type this one up and submit electronically.  But do score your response, study the canonical solution, and take a look at the sample solutions.

Attachments:
ap08_q1.pdf
ap08_q2.pdf
ap08_comp_sci_a_q1.pdf
ap08_comp_sci_a_q2.pdf

4/18 - GridWorld review
GridWorld review:  Do this in class today.  5 multiple choice questions plus FRQ #2.  (Skip FRQ #1.)  If you want to take this like a test, give yourself about 10 minutes for 5 M/C questions, and 26 minutes for the FRQ.  If you'd rather do this open notes, open code, open time, open friends, your choice.
<GridWorld_Samp_Quest.pdf>

4/15 - - Stockpile +
warmup)
 int a=0;
 int b=0;
 for (;;)
    if (++a % 7 == 0 && ++b % 7 == 0)
      break;
 System.out.println(a + " and " + b + " are divisible by 7!");

 // expected result:
 // actual result:
 // what the !@#$ happened?

a) AP 2009 FRQ q2: Stockpile Critter
 Spend 5 minutes familiarizing yourself with the Quick Reference and re-familiarizing yourself with the GridWorld code. Then give yourself 30 minutes to do this on paper.
 Then open the attached canonical solution and scoring guidelines and in a different color, score your program.

Attachments:
ap09_q2.pdf
ap09_q2_scoring.pdf
ap09_q2_canon.pdf

4/13 - 2009 FRQs AP
In class:  Just open the questions, not the canonical solutions or the scoring yet.  Since we only have time for 3, let's calculate an overall score based on just these. 

For homework:  Score FRQs and examine canonical and sample solutions.  We'll score the overall test on Friday and go over the multiple choice.
Attachments:
ap09_q1.pdf
ap09_q3.pdf
ap09_q4.pdf
ap09_q1_canon.pdf
ap09_q1_scoring.pdf
ap09_q3_canon.pdf
ap09_q3_scoring.pdf
ap09_q4_canon.pdf
ap09_q4_scoring.pdf

4/12 - ap09 multiple choice
Attachments:
ap09MCanswers.pdf
ap09_mc_score_stats.pdf

4/11 - frq2008-4
This is the FRQ I was *going* to give you on your test last week.  For most of you, it will be a litlte harder.  (Mean score was 3.44.)  Less code, but more abstract thinking.  Try coding it up on paper.
(If you want to try coding it up on a computer after your paper attempt, you can.  But I'm not requiring it.)
- - - -
Now carefully score it, and think about the given solutions.  It really doesn't require much code.  But it does require understanding everything they tell you in the directions.
- - - - -
My solution for the warmup:
(Don't look yet if you still want to work on it.)

public boolean scoresIncreasing(int[] scores) {
    for (int i=1; i<scores.length; i++)
      if (scores[i]<scores[i-1])
        return false;
    return true;
 }

Attachments:
ap08_q4.pdf
ap08_comp_sci_a_q4.pdf

4/5 - test 6
 We've covered a lot since our last GridWorld test:
  ArrayList
  interfaces
  recursion
  big-O
  Comparable
  sorting
  searching

4/4 - review: BPJ Contest Type Problems 41, 45, 51
test review:  BPJ Contest-Type Problems for
  41 sort
  45 comparable
  51 binary search
 
answers
41 B D E A C
      D B D C B
      C B D B A
      A D C
45 B E A E A B
51 C C C D A B B

4/1 - review: BPJ Contest Type Problems 43, 38, 39
test review:  BPJ Contest-Type Problems for
   43 ArrayList
   38 Interfaces
   39 Big-O

3/30 - BPJ 48 flow chart
BPJ 48: Flow Charts Optimizing

This looks kinda fun.  Let's do the projects.

3/31: revised spec:
1) increase the iterations to something that will give
    a more meaningful slow time than 8 seconds. Try
    7 billion.
2) Put all 3 optimization levels into a single program
    and prompt the user to choose which level. Use a
    switch/case statement to select between the 3.
3) Record the performance of your home computer for this task. Jot it down in the comments somewhere, along with some info about its processor/age.  Let's see who's got the fastest and slowest computers at home.

3/28 - BPJ 51 Binary Search
Blue Pelican Java 51: Binary Search
  projects and Exercise questions

- - - - -

P.S. Before (or after) you mess up the second project, reread the last two paragraphs of the instructions very carefully. They're asking you to write a generic binary search that works for any (appropriate, ahem) Objects, not just Integers!

3/16 - frq2006-3
Sorting ain't (wasn't) just something you need to be familiar with for the multiple choice.  You may need to be able to code it up.  As AP students had to in 2006.  And you probably remember diddly about merge sorts because you didn't have to answer any questions on it.  Boo hoo, poor you.

Try this FRQ first on paper, without using any references, as if you were taking a test.  (You will eventually score this.  It builds character.)  (Or maybe it's not even that hard?)  Then treat it as an assignment, code it up on the computer, using whatever references you need.  We'll make the scoring guide and canonical solution available later.

Due: end of period tomorrow. Tomorrow, we'll also score your paper response. E-submit your Tester class.
Attachments:
ap06_q3.pdf
ap06_q3_ans.pdf

- - - - -

Also, watch (and listen) to these:
- https://www.youtube.com/watch?v=WaNLJf8xzC4
- http://www.youtube.com/watch?v=t8g-iYGHpEA
- http://www.youtube.com/watch?v=m1PS8IR6Td0
- http://www.youtube.com/watch?v=vxENKlcs2Tw

3/15 - BPJ 45 Comparable proj 1
due [+2 days]

Blue Pelican Java 45: Comparable and Comparator
We're going to try skipping the Exercise questions and go straight to the project.  Read the Comparable explanations carefully, but you can skim over Comparator for now.

There are 3 projects.  This assignment is just the first one, sorting by balance.

3/2 - frq2006-2
0) Read Blue Pelican, Appendix L.

1) 23 minutes, on paper, do AP 2006 FRQ #2.

2) Type in all the code (theirs and yours) on a computer and make it work.
The purpose of this is to try to find all the errors in your handwritten code before looking at the solution. You'll need to also create a Tester class to instantiate a Vehicle object and run its methods.  Submit only your Tester.

3) In a different color, score your original paper answer and turn that in tomorrow. You'll want to try to grade your code as harshly as possible rather than generously. Finding excessive fault with your code will help you a lot more than missing faults.

Attachments:
ap06_q2.pdf
ap06_q2_scoring.pdf

3/11 - BPJ 41 proj: Multi Key Sorting
Blue Pelican Java 41 project:  Multiple Key Sorting
  We'll give you a couple days for this.  You'll have to refresh your knowledge of file reading and/or copy the BaseClass given elsewhere in Blue Pelican.  There's certainly more than one way to accomplish multiple key sorting, so give it a whirl.

(Also submit electronically the various sorting methods you typed in, to the previous assignment's dropbox)

To compare two strings...yeah, you know how.

3/10 - BPJ 17 exercise: String methods
warmup:  Javabat String-2 - getSandwich

Blue Pelican 17 Exercise
  questions on advanced String methods
(We're going to need one of them for tomorrow's sorting project.)

3/8 - BPJ 41 insertion quick merge
Blue Pelican Java 41
Insertion Sort - Project, Exercise
Quick Sort - Project, Exercise
Merge Sort - Project

3/7 - BPJ 41 bubble + selection sorts
Bubble Sort:  Read and do the Project (which just means type in their code.  Please at least type it in rather than copy and paste, just so you'll be more familiar with the code.)  (Don't worry about turning in any of the code yet...)

Selection Sort:  Read, Project, Exercise questions.

3/4 - BPJ 39 exercise: Big O
1) Blue Pelican 39 Exercise: Big O
read and answer questions
2) See attached images for help with yesterday's Hanoi problem.
Attachments:
wu_hanoi1.jpg
wu_hanoi2.jpg

3/1 - towers of hanoi

Recursion is mostly about making life easier for the programmer.  But there are some problems that can only easily be solved recursively.  Recursion is mostly about making life easier for the programmer.  But there are some problems that can only easily be solved recursively.  An example is the classic Tower of Hanoi game.

Google "tower of hanoi".  Ignore the first link (Wikipedia).  The next 8 hits are all Java applets of the game.  Try playing until you get the feel for it.

Your assignment is to write a program to solve the Tower of Hanoi.  At its simplest, one can generate the list of moves in about five lines of code.  Depending on how much you want to do, there are varying degrees you can do:

simplest - just list moves
 from -- to
 1 -- 2
 1 -- 3
 2 -- 3

keep track of which disk
 [disk 1] 1 -- 2
 [disk 2] 1 -- 3

graphical representation with numbers representing disks
 321--
 ---
 ---

 32---
 1---
 ---

ASCII art
     |
    =
   ===
  =====

or even real Swing graphics if you're crazy

- - - - - -

the recursive algorithm:

So your recursive method's signature might look like this:

public static void towersOfHanoi(int numDisks, int fromPost, int sparePost, int toPost) {}
   end case:  If you just have one disk, moveOne(fromPost, toPost)
   recursive case:  move N-1 disks to the spare post, then move the Nth disk to the destination post, then move the N-1 stack from the spare to the destination post

simplest moveOne method:
 public static void moveOne(int fromPost, int toPost) {
   System.out.println(fromPost + " -- " + toPost);
 }

- - - - - -

sample output for a 4 disk tower:

1 -- 2
 1 -- 3
 2 -- 3
 1 -- 2
 3 -- 1
 3 -- 2
 1 -- 2
 1 -- 3
 2 -- 3
 2 -- 1
 3 -- 1
 2 -- 3
 1 -- 2
 1 -- 3
 2 -- 3

.2/24 - javabat recursion practice
Do any additional 5 Javabat Recursion-1 problems and get all warm and comfie with thinking recursively.

.2/28 - BPJ 40 Project: ModFib + Javabat fibonacci
recursion practice:

Blue Pelican Java 40 Project: Fibonacci
  submit just your ModFib class

Also do the Javabat fibonacci (bunnyEars-1) problem.

.2/25 - Blue Pelican 40 Exercise: recursion
Blue Pelican 40:  **Recursion**

Recursion is one of those things that only makes sense to true computer nerds...like you guys!  And even then not at first.  But it's kind of cool.  Read this one a little more carefully than usual, and do the Exercise questions.

Also, do Javabat factorial and fibonacci.

p.s.  levity attached.
Attachments:
foxtrot_avatar.gif

.2/22 - Blue Pelican 38 Exercise and Project   [move to after HF interfaces?]
a) If you didn't do well on the test FRQ, *please* look over the attached canonical solution carefully and see where you didn't follow the instructions. I've said this before, and I'll say it again: Well over 50% of computer science is correctly following instructions.

b) Blue Pelican 38, read and do Exercise questions. (You may want to look at the GridWorld grid classes for a live example.)

c) Blue Pelican 38 Project: Linear Function interface
Due [+2 days]. Submit only your LinearFunction class.
For the getRoot() method, I believe it's supposed to find the zero i.e. the x-intercept.

Attachments:
ap08_comp_sci_a_q3.pdf

2/17 - Blue Pelican 22 Exercise
Blue Pelican 22, read & do exercise

2/15 - ArrayList glitch
The advantage of ArrayLists is that they can grow and shrink, right?

Write a simple program that creates an ArrayList of Integers, and populate that Arraylist with the numbers 1-9 in some *arbitrary* order.  Print out the values in your ArrayList.  Then iterate through the list and remove all the odd numbers.  Print it out again.  WT#?  Now figure out what's going on and how to fix it.

(There are two simple solutions. See if you can figure out both.)

2/16 - [test 5 GridWorld]

2/14 - GridWorld review questions
In the Schoolloop locker, you will find the GridWorld Quick Reference.  You can use this on the AP test, so you should start getting familiar with it.  I'll make photocopied sets for you, but for today, use the electronic version.

Attached are some practice questions to help you review for your test tomorrow.  Answer them on a piece of paper.  Correct answers will be posted at the end of the period.
Attachments:
gwquestions_barrons90.pdf

[2/ - ]
Test on GridWorld Wednesday.  I'd suggest starting by first rereading the role play scripts, and then *re*reading the actual GridWorld code.  Lots of you are still very unfamiliar with the code, despite having *needed* to look at it to answer the questions...

[2/10 - battle critter name
You were all supposed to give me the name of your battle Critter by end of period yesterday.  Half of you didn't, so you're *late* on this assignment.  Attached is the list so far.  I'll update it as I get more names, and keep on docking points as long as I don't.

File updcated 2/11 12:43am.  We're just missing Daniel, Kevin, Fiona, and Edward.
<critters.txt>

2/7 - Battle Critter
Battle Critter:
Make your own creature for GridWorld. We'll put them all on a common board and see which one survives.  Last man standing wins.  To prevent complete chaos, there are some ground rules, attached.  Your creature can extend Critter, but it doesn't have to.  You  may decide you'd rather extend Bug, or a generic Actor, or something else entirely.  (Flower? Rock?)

The coding may not take much time, but thinking about a strategy can, so we'll give you till...next Wednesday?  and we'll run other assignments concurrently.

To customize your image, put a GIF file (preferably 48x48) with the same name as the class in the same directory as the class (e.g. DancingBug.gif).
Attachments:
GridWorld_Project6_YourCreature.pdf

p.s. Also, PLEASE add some comments describing what you're creature is actually supposed to do.  Don't make me try to figure it out from your code.

2/4 - GridWorld Qritter qrestions
Part 4 of the GridWorld Student Manual:
Again, as you read, be sure to look at the relevant parts of the GridWorld code in your framework directory.
Due [+2 days incl. weekend]:  questions for Sets 7, 8, and 9
 Rather than doing the programming exercises on p. 35, just read them and think them through.  For each, write down level of difficulty for you (e.g. easy, medium, hard), how long you think it'd take you to code up, and at least one thought about it.

2/2 - Blue Pelican 43 Project: Big Bucks

Yay, practice using ArrayList! Relatively straightforward assignment, but I'll give you till the end of period tomorrow anyway.  Just submit your Tester.

2/1 - BPJ 21 + 43 Exercise
Blue Pelican 43 covers ArrayList.  But before you do that, you'll need to look at BP 21 to understand wrapper classes and the difference between an integer and an Integer. So let's read and do the Exercises for 21 and 43.

1/28 - GridWorld nitty gritty
Part 3 of the GridWorld Student Manual:
This section gets dense.  Lots of details you need to learn.  So it's worth reading a little more carefully than the last two.  As you read, be sure to look at the relevant parts of the GridWorld code in your framework directory.
Today: Location (p. 19 questions) and Grid (p. 21)
[next]day: Actor (p. 23 and 25 questions)

1/26 - BoxBug
Part 2 of the GridWorld Student Manual:
Read pp. 10-15, add the Set 2 questions to the ones you did Friday, and do the Exercises.  Like the while/for projects, turn in the last one you completel.  Unlike the while/for projects, don't just skip to the last one; do them in order.

1/24 - enter gridworld
download from my Teacher Inbox:
 the GridWorldCode folder
 GridWorldScripts_Lew
 ap07_gridworld_studmanual
 
Add gridworld.jar to the BlueJ libraries. gridworld.jar is a file in the GridWorldCodeBlueJ folder. You add it to BlueJ's libraries by following these steps:
- In BlueJ, go to Preferences/Libraries.
- Select "Add", choose the gridworld.jar file, and click Ok.
- Restart BlueJ.
(If that doesn't work i.e. after restarting, library disappears, an alternative method is to place a copy of the JAR file in the BlueJ/lib/userlib/ directory.)

Read through chapter 1, play with projects/firstProject/bugRunner, and do Set 1 questions (p. 6) and Exercises (p. 8)

P.S. To load a project, you have 3 options:
1. copy and paste
or create a new project and then either
2. Project->Import the non-BlueJ project _directory_, or
3. Edit->Add Class From File to the class _file_

1/19 - semester 1 final

1/11 - BPJ 35 Project: Matrix Multiplication
Blue Pelican 35 Project: Matrix Multiplication

1/11 - BPJ 35 Exercise
Blue Pelican 35: 2D arrays - do the Exercise

1/10 - Scale 'Em Up or Down
Okay, now that you figured out how to get all the individual pieces working, it should be easy to complete our original task:  scaling up or down your Christmas graphic.

Both filename and scaling percentage should be command line arguments.  (Things you type into the {} in BlueJ after you right click on "void main" but before the program actually runs.  Strings need to be quoted.  Sample:  {"graphics.java", "150"} )

The one thing to figure out:  You don't want to scale every number on every line.  For example, you won't want to scale your Color definitions.  Only the numbers that specify point coordinates and distances.

1/7 - Double 'Em to file
Next step:  Rather than output to the terminal, output to a file.

Read Blue Pelican 26.  Modify your code to save the output to a new file.  Once you can save to a fixed filename, add these features:
1. If the original filename was booger.txt, the output should be boogerx2.txt
2. Enter the input filename through args[] i.e. as a command line argument

- - - - -

For those of you still struggling to get the doubling to work, you can try to fix your algorithm, or you can use mine:
- split the line twice, into an array of the numbers and an array of the nonnumbers
- double the numbers.  You'll need to parse them into integers and then back into strings.  (note: the first element may be "".)
- create two new string arrays "first" and "second". If the first thing in the line was a number, first[] should point to the same reference as the numbers array, and second[] to the nonnumbers.  Otherwise, vice-versa.
- print alternating elements starting with the second[] array, because its first element is an empty string.  If second[] has more elements than first[], you'll probably need an additional print statement to get the last second[] element.
- - - - -
Actually, this may work easier:
 - Split out your numbers into an array. Then, go back through the string and replace all the numbers with a placeholder string.  You can then replace the placeholders with the doubled numbers.
 - This may not actually get rid of the problem of empty strings.

Make sure your test file has all possible cases of sentences beginning and ending with numbers or non-numbers.

1/5 - Double 'Em from file
Next step:  read your input from a file rather than the keyboard.

This is probably the best, simplest example of how to read from a file:
   http://www.java2s.com/Code/Java/File-Input-Output/ReadfileusingScannerclass.htm
But rather than declare the exception in the method signature, it's probably better to localize it within a try-catch block like this:
   http://www.coderanch.com/t/409945/Beginning-Java/java/FileReader-or-Scanner

(If you want more explanation, you can look at Blue Pelican 24 and 25 (and a slightly different way to read from a file by storing the whole thing in an array). Or try the original Sun documentation for FileReader (
http://java.sun.com/developer/JDCTechTips/2004/tt1201.html), which Oracle seems to have lost in their takeover of Sun, but can still be found in the web archive:
   http://web.archive.org/web/20080801202752/http://java.sun.com/developer/JDCTechTips/2004/tt1201.html (second example)
 or also here:
   http://www.java-tips.org/java-se-tips/java.util/scanning-text-with-java.util.scanner-3.html
  The BufferedReader stuff is the pre-Java 1.5 old way that you can ignore. 1.5 gave us Scanner which makes both keyboard and file input a little easier. Those are the examples to try to understand.)

Do:  Create a short text file with at least four sample sentences with numbers in various positions, and try to double those rather than from the keyboard.  You can use Notepad to create the file, or you might even be able to use BlueJ (just save but don't compile). If the file is in the same directory as your project, you shouldn't even need to specify the full path, just the filename.  (Actually, it may be better to create the text file in BlueJ because Windows puts weird ^M characters at the end of lines in its supposed text files.)

1/4 - Double 'Em Right
We're trying to get to where we can scale all the numbers in your Christmas tree program by a common factor to scale up or down your drawing.  The next step:

Modify your Count 'Em Right program (or make one from scratch) that will take a line and double all the numbers in it.  A typical run would look like this:

  Type in a sentence and press ENTER.  The 2 mice left 296 poops in Mr. Joo's desk.
  The 4 mice left 592 poops in Mr. Joo's desk.

  Type in a sentence and press ENTER.  exit

It seems like there ought to be a way to do this directly.  But I haven't found it.  No worries, you know more than enough Java to be able to come up with an indirect way of doing this.  There are many.  We'll see who comes up with the best ways of doing this, and use those for our next step.

1/3 - something review, something new
Since we remember soooo much of our lovely Java syntax after our two week break (yeah, me neither), let's ease our way back into it with some (mostly) review:
 new stuff:  read Blue Pelican p. 18-4
 do the Exercise questions (by beginning of tomorrow)
 do the first Project: Count 'Em Right (by 8:15a Wednesday)
(Didja read Appendix AC when you did the questions? Come on, now, go back and read Appendix AC.)

(12/16/11 - holiday reading
Head First, pp. 240-256
 Good stuff to tie down your knowledge of constructors and object creation.  Test will be the second day back from break.

- - - - -

Also, a bit of optional reading that some of you might find interesting enough to read in its entirety, about the first computer programmer. 

-   -   -

Subject: Happy Birthday Ada Lovelace
 From: John McC...)

12/13 - intro to graphics
/*
 * Sample Graphics
 *
 * Since we have a few days to fill till Christmas break, let's dip our toes
 * into graphics.  Blue Pelican has nothing, Head First...has too much, so use
 * the internet as your reference, and look up the commands below, or just
 * play with it to figure out what they do.
 *
 * Then, draw a Christmas tree.  Or a snowflake?  Or something else holiday-/
 * vacation-/gonna-get-sleep-soon-related.
 */

import javax.swing.*;  // for JFrame
import java.awt.*;     // for Graphics and Container

public class SampleGraphics
{  
    public static void main (String[] args)
    {
        JFrame win;                 // JFrame Graphics setup
        Container contentPane;
        Graphics g;
      
        win = new JFrame("My First Graphics");  // window setup
        win.setSize(300,200);
        win.setLocation(100,100);
        win.setVisible(true);
      
        contentPane = win.getContentPane();   // activates graphics in window
        g = contentPane.getGraphics();
      
        //  If you get a blank window, your computer's speed (lack thereof?)
        //  requires this delay in order to give the window time to appear
        //  before attempting to draw on it
        try {Thread.sleep(400);} catch (Exception e) {}
      
        g.drawRect(50,50,100,30);   // draws outline rectangle
      
        g.setColor(Color.GREEN);
       
        g.fillOval(100,150,50,20);  // draws solid ovals and circles
      
        // set color to any RGB value
        g.setColor(new Color(255,20,175));
       
        // draw a triangle
        Polygon tri1 = new Polygon();
        tri1.addPoint(200,100);
        tri1.addPoint(250,150);
        tri1.addPoint(180,180);
        g.fillPolygon(tri1);       // drawPolygon() would create outline only

   }
}



12/14 - test 4
covers object-oriented stuff:  super/subclass, inheritance, constructors, overriding, overloading, shadowing, abstract.
does not include interfaces.

12/12 - happy birthday, Ada Lovelace
A bit of optional reading that some of you might find interesting enough to read in its entirety.  Ada Lovelace, incidentally, had the same birthday as our own dear Dave Zheng.
- - - - -
Subject: Happy Birthday Ada Lovelace
From: John McCormick
Date: Fri, 10 Dec 2010 08:43:27 -0600
Reply-To: "AP Computer Science"
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

On December 10, 1815, Anna Isabella (Annabella) Byron, whose husband
was Lord Byron, gave birth to a daughter, Augusta Ada. Ada's father was
a romantic poet whose fame derived not only from his works but also from
his wild and scandalous behavior. His marriage to Annabella was strained
from the beginning, and Annabella left Byron just a little more than a
month after Ada was born. By April of that year, Annabella and Byron
signed separation papers, and Byron left England, never to return.

Byron's writings show that he greatly regretted that he was unable to
see his daughter. In one poem, for example, he wrote of Ada,

I see thee not. I hear thee not.
But none can be so rapt in thee.

Byron died in Greece at the age of 36, and one of the last things he
said was,

Oh my poor dear child! My dear Ada! My God, could I but have seen her!

Meanwhile, Annabella, who was eventually to become a baroness in her own
right, and who was herself educated as both a mathematician and a poet,
carried on with Ada's upbringing and education. Annabella gave Ada her
first instruction in mathematics, but it soon became clear that Ada's
gift for the subject was such that it required more extensive tutoring.
Ada received further training in mathematics from Augustus DeMorgan, who
is today famous for one of the basic theorems of Boolean algebra, which
forms the basis for modern computers. By the age of eight, Ada also had
demonstrated an interest in mechanical devices and was building detailed
model boats.

When she was 18, Ada visited the Mechanics Institute to hear Dr.
Dionysius Lardner's lectures on the "difference engine," a mechanical
calculating machine being built by Charles Babbage. She became so
interested in the device that she arranged to be introduced to Babbage.
It was said that, upon seeing Babbage's machine, Ada was the only person
in the room to understand immediately how it worked and to appreciate
its significance.

Ada and Babbage became good friends and she worked with him for the rest
of her life, helping to document his designs, translating writings about
his work, and developing programs to be used on his machines.
Unfortunately, Babbage never completed construction of any of his
designs. Even so, today Ada is recognized as being the first computer
programmer in history. That title, however, does not do full justice to
her genius.

Around the time that Babbage met Ada, he began the design for an even
more ambitious machine called the "analytical engine," which we now
recognize as the first programmable computer. Ada instantly grasped the
implications of the device and foresaw its application in ways that even
Babbage did not imagine. Ada believed that mathematics eventually would
develop into a system of symbols that could be used to represent
anything in the universe. From her notes, it is clear that Ada saw that
the analytical engine could go beyond arithmetic computations and become
a general manipulator of symbols, and thus it would be capable of almost
anything. She even suggested that such a device could eventually be
programmed with rules of harmony and composition so that it could
produce "scientific" music. In effect, Ada foresaw the field of
artificial intelligence over 150 years ago.

In 1842, Babbage went to Turin, Italy, and gave a series of lectures on
his analytical engine. One of the attendees was Luigi Menabrea, who was
so impressed that he wrote an account of Babbage's lectures. At age 27,
Ada decided to translate the account into English, with the intent to
add a few of her own notes about the machine. In the end, her notes were
twice as long as the original material, and the document, "The Sketch of
the Analytical Engine," became the definitive work on the subject.

It is obvious from Ada's letters that her "notes" were entirely her own
and that Babbage was acting as a sometimes unappreciated editor. At one
point, Ada wrote to him,

"I am much annoyed at your having altered my Note. You know I am always
willing to make any required alterations myself, but that I cannot
endure another person to meddle with my sentences."

Ada gained the title Countess of Lovelace when she married Lord William
Lovelace. The couple had three children, but Ada was so consumed by her
love of mathematics that she left their upbringing to her mother. For a
woman of that day, such behavior was considered almost as scandalous as
some of her father's exploits, but her husband was actually quite
supportive of her work.

In 1852, Ada died from cancer. Sadly, if she had lived just one year
longer, she would have witnessed the unveiling of a working difference
engine built from one of Babbage's designs by George and Edward Scheutz
in Sweden. Like her father, Ada lived only until she was 36, and, even
though they led much different lives, she undoubtedly admired Byron and
took inspiration from his unconventional and rebellious nature. At the
end, Ada asked to be buried beside him at the family's estate.

In the 20th century, navy commander John Cooper honored Ada Lovelace by
naming the US Department of Defense's new programming language after
her. Ada is perhaps the only language to have applied software
engineering principles to its design. After several years of
requirements gathering, William Whitaker's team produced four
generations of language specifications (strawman, woodenman, tinman, and
ironman). The DOD then held a competition to design the language. Cii
Honeywell Bull of France led by Dr. Jean Ichbiah won the final
competition. For his accomplishments, Dr. Ichbiah was awarded the Legion
d'Honneur by the President of France.

Since its first ISO standard was approved in 1987, Ada has evolved with
new standards in 1995 and 2005. The next standard will be approved in
2012. Ada was the first object-oriented language to have an
international standard. Ada is the language of choice in projects where
failure is not an option. The safety critical software on board nearly
every, high speed train, aircraft, and spacecraft is written in Ada.
Praxis High Integrity Systems, the only company known to give
unrestricted warranties on the software they develop, work exclusively
in a subset of Ada called SPARKAda. SPARKAda provides the means for
proving that software meets its specification. Replacing much of the
laborious testing of high integrity software with rapid mathematical
proofs allows Praxis to consistently underbid competitors using more
mainstream but less precise languages. Praxis is currently developing
the software for the United Kingdom's new en-route air traffic control
system. At an estimated 1.2 million lines of code, it will be the
largest software system ever formally verified.

Ada has been supporting multiprocessor, multi-core, and multithreaded
architectures as long as it has existed. While some have predicted it
will be another decade before there is a programming model for
multi-core systems, programmers have successfully used the Ada model for
years. In February 2007, Karl Nyberg won the Sun Microsystems Open
Performance Contest by building an elegant parallel Ada application. The
parallel Ada code he wrote a decade before provided the foundation of
this success. In the December 2009 competition, Ada placed first of all
languages in the Ubuntu multi-core computer language benchmarks game.
The Ada solution was 30% faster than C, 40% faster than C++, 100% faster
than Java, and 32,400% faster than Python in this multi-core completion.

The same feedback that Ada provides developers of mission-critical
software makes it easier for beginners to learn programming. The
stability of the language allows compiler writers to concentrate more on
the human side of programming than on adding new features. The GNU Ada
Translator (GNAT) includes an expert system that analyses a student's
programming style and a database of previous students' errors to tailor
its syntax error messages. Introductory programming classes taught using
Ada have consistently higher retention rates than the more popular
languages. Perhaps Ada Lovelace would be pleased that her language
namesake is particularly effective in retaining women in our profession.

The film "To Dream Tomorrow" from Flare Productions, www.flarefilms.org,
tells the story of Ada Lovelace and her contributions to computing. I
highly recommend it for your AP classes.

John W. McCormick mccormick@cs.uni.edu
Professor
Computer Science Department
University of Northern Iowa voice (319) 273-6056
Cedar Falls, IA 50614-0507 fax (319) 273-7123
http://www.cs.uni.edu/~mccormic/

12/10 - test review: BPJ 36 contest-type problems
abdde
dadeb
bdcee
b

12/8 - HF reading: interfaces
Head First:  read 211-229
Again, kinda heavy reading.
Do:  the end of chapter exercises, pp 230-232.  By hand, not typed.  Yes, I know you have the answers on 233-34 and all you have to do is copy.  You wanna have no idea what an interface is when you have to start using them, go right ahead, buddy boy.

12/8 - roshambetter
make a more efficient determineWinner() method.  submit both your old and new methods (and only the determineWinner() methods) and describe how many steps each requires (worst case or mean, your choice).
assignment is due tomorrow, but the best-in-class and beat-Mr.-Joo contest runs until 8am [+1 week].

12/7 - roshambo
Rock, Paper, Scissors.

Lab10d.java and RockPaperScissors.java have laid out the framework for a RoShamBo game.  See if you can flesh it out.

(BiggestString.java is included because it shows an example of a neat safety net for the default constructor.)

The methods should do this:
   setPlayers(): Doesn't do anything. Delete it. Even the author of the project didn't use it in his standard solution. How lame is that?
   RockPaperScissors(String): what constructors do: set the instance vars.  populate playChoice from the input, compchoice randomly
   RockPaperScissors(): set playChoice = compChoice = ""
   determineWinner(): returns third line of output i.e. who wins and why
   toString(): returns first two lines of output i.e. values of playChoice and compChoice

That way, we can practice using toString i.e. just print the object directly for part of your output.

Attachments:
BiggestString.java
lab10d.doc
Lab10d.java
RockPaperScissors.java

12/6 - HF serious polymorphism reading 1
Head First, 190-191, 197-210
This is mostly review, but...for many of you, you can't review what you don't already know, no?  And we need to have an OO (object-oriented) test sometime soon.  Probably next week.

12/1 - BP 36B + extend Robot
2 in 2 (2 assignments, 2 days)
 1) Blue Pelican 36, Exercise B
 2) extend the Robot class.
You can use your existing code (or if you never
got it to work, you can use mine, attached). 
Suggestions:
 - heavy duty vac, can suck up 2 items at a time
 - random vac, moves randomly every move
 - wide vac, can clean more than 1 tile at a time
 - slow vac, half a trash at a time?
 - sloppy vac, for every 3 moves, it drops a piece
     of trash
 - whatever
Keep your instance variables private. You'll have to make getters/setters for your instance vars and change the access level of some methods.
<RobotGeneric.jar>

11/23 - FamousPoets
read Head First: bottom half of 180 - 189

The purpose of this assignment is to make the simplest possible program that implements inheritance.  The idea I've come up with makes no claims to be the best, easiest way to do this, so if you think you have a better idea, by all means give it a whirl.  Otherwise, try this:

superclass FamousPoet (FamousPerson, whatever)
 instance variables: name, lastName, saying
 method: speak() - prints their saying like this:
  "blah blah blah" --[first name] [last name]

four subclasses
  In at least one subclass, override a method.
  In at least one subclass, shadow an instance variable.

tester
 make four famous person objects
 use a loop to make each one speak (polymorphism!)

example: With a Shakespeare subclass, a modern descendant of the bard might say:
"To be or not to be OVER NINE THOUSAND!!  That is no question at all!" --Jimmy Shakespeare

The purpose of the assignment isn't so much to follow my specifications to the letter or make a program that has any practical use. It's to play with inheritance, and overriding, and shadowing, and start to get a feel for how they work, and also how they don't work. In order to get it to work at all initially, you may have to play with access levels (private/public). How might you override speak()? Maybe one of 'em stutters, or talks backwards, or....

NOT due tomorrow.
 
11/29 NEW NOTE: due Wednesday.
NEW requirement: read 190-191. overload a method or constructor.

11/22 - intro to inheritance (HF+BP)
A. Head First:
  read 177-top half of 180
  add these to your HF questions:
    p.179 Sharpen Your Pencil
    8. Does the “IS-A” inheritance test work both UP and DOWN an inheritance
tree? Give an example.
    9. In your answers to the HF chapter 2 questions, which of your class/subclass examples fail the IS-A test? If none, or more likely if you can't find your answers, use a friend's.

B.  Blue Pelican
  Lesson 36.  Read it, and do Exercise A.
  There's *a lot* here, so don't try to understand everything.  Focus on big concepts and what you need for the exercise, not so much every single detail.  We will definitely take a second pass through this material.

11/17 - array practice, dip into Objectville

1) Blue Pelican 19 Projects - first do 1, then turn in 2

2) Head First - Better Living in Objectville
 read: 165-176
 do: these questions
1. What is the process of moving common elements (methods and variables) into another class? What is the name of this special new class?
2. Once superclasses are created, what main purpose do they serve?
3. In page 167, it looks like there are “rotate()” and playSound() methods in both the “Shape” and “Amoeba” classes. Shouldn’t the Amoeba rotate() and playSound() methods be abstracted into the Shape class? Why does the Amoeba class have its own versions of rotate() and playSound()?
4. So when you have a method in both a superclass and a subclass, how does the JVM know which one of these to call?
5. In the inheritance tree on page 168, there is a FriedEggMan who inherits from a SuperHero superclass. FriedEggMan does not override any of the superclass’ methods, so what makes a FriedEggMan unique? Does he inherit anything else?
 plus: p. 176 Sharpen Yo' Pencil

11/10 - battleship / Head First chapter 6
due midnight [+1 week]:

Work through chapter 6 in Head First. Don't worry so much about the new Java features. Focus on how they decided to split up their program into classes and methods. This is the hardest part of programming to do well.

How much of your program is straight out of the book and how much is your own is up to you, but it's much better to have a simple program that's entirely your own rather than a complex one using a lot of the book's code that you don't entirely understand.

Start simple and slow build in complexity rather than try to attempt everything at once. For most of you, I would strongly suggest that you start as small as possible:
    1. Start with just a 1D array with one occupied square, and get the program to take your guess and tell you if you hit it.

    2. Then make the placement of the ship random.

    3. Then make it 3 squares and you "sink" when all 3 are hit.
    4. Lastly, place multiple ships and grapple with the overlap problem.
If and only then should you even worry about 2D boards.

If you end up with a 1D board instead of 2D, that's okay. But at the end, you should have a working program entirely your own that you *understand*.

Use comments so I can figure out what you're doing. Or trying to do.

11/9 - Head First chapter 5
Read Head First Java, chapter 5.

New concepts:
 flowchart
 pseudocode ("prep code"), test code
 Integer.parseInt
 enhanced for (foreach)

Do:
 make flowchart of *your* game plan (see p. 97 example)
 p. 107 (no points if same as p. 108) 

Expect: small reading quiz

11/5 - plan for battle(ship)
You know the game Battleship?  Where you have a grid that you put your boat pieces on, and you take turns calling out coordinates to fire on, and the other person tells you if you hit or missed?  And then the commercial always ends with "You sank my battleship!"?

Let's prepare to make one.  Let's assume a one player game where the computer randomly places the ships and you have to guess.  I don't want to see any code yet, just a plan.  How would you make one?  How would you divide it into methods and/or objects?  What will each part do?

11/5 - [test 3 - arrays, methods, objects]

11/3 - test 3 review:
Contest Type Problems in the Blue Pelican lessons:
  19 (except 2, 7, 10)
  20
  16
plus 18 Project: Array of Hope (on paper, not electronic)

11/2 - Blue Pelican lesson 19
Read Blue Pelican lesson 19.  Good information directly pertaining to problems many of you will soon encounter during your Battleship project.

Do the Exercise questions.

10/27 - Robot + HF Ch 4 questions
[at least two days]
<4questions.pdf>
<ap04_4.pdf>

10/26 - fraction objects
Time to get object-oriented.  Create a Fraction object class:
- non-public numerator and denominator instance variables
- getter and setter methods for them
- two print methods, one that prints your fraction like this
   15 / 20
 and another that does this
    15
    ----
    20
- don't forget your constructor!
- optional level 1: reduce and/or isReducible methods
- optional level 2: the above two methods use a getFactors method that returns an array, and you use your smallestCommon method to find the common factors.
(for this last one, since we don't know how many factors a number has, we'll have to pick an arbitrary size for our array and populate the extra slots with a dummy value, either 0 or -1 or Integer.MAX_VALUE.  and you may want to turn your smallestCommon into largestCommon.  and...)

You'll also need a FractionTester class to actually run these.

- - - - - -

addendum:

There's a fair amount of confusion about the overlap of function between the constructor and the setters/getters.

The constructor sets the instance variables initially, and then the setters can be used to change them any time afterwards. For this program, we don't actually need to use the setters or getters ever. But we're still writing them to get into the practice of putting them in every program. You should always initialize instance variables with the constructor, so that the variables are populated from the moment the object exists.

10/25 - BPJ 20 static
Read Blue Pelican, Lesson 20.
Do 20 Project: Distance To Line
(Refer back to Lesson 6 for the appropriate Math class methods.)
(Oh...yeah, leave these class instance variables public, just this once...)

10/25 - encapsulated BankAccount
Let's take a first practice with encapsulation. Make a copy of your Overdrawn At The Bank project, and then make the instance variables private. Breaks the program, right? Now fix it.
- Make getter(s), using Head First's ElectricGuitar class as a model (but unlike HF, don't forget to label yours "public").
- Modify your Tester to use your getter(s) rather than access the instance variables directly.

10/20 - HF4 + smallest common number
Read Head First Java, chapter 4

Do:
nums1 = { 1, 2, 4, 6, 7, 9, 13, 14, 17 };
nums2 = { 0, 3, 5, 8, 9, 11, 12, 14, 17, 18, 20 };

Write a method for which:
- You will pass to it two arrays of sorted integers
- It will return the smallest value common to both arrays
1) simple brute force way
2) elegant, efficient, natural way

basic structure:
public class arrayCrawler
{
   public static void main(String[] args)
   {
       int[] nums1 = { 1, 2, 4, 6, 7, 9, 13, 14, 17 };
       int[] nums2 = { 0, 3, 5, 8, 9, 11, 12, 14, 17, 18, 20 };

       //actual method calls and prints go here
   }

   public static blah blah lowestCommon1( blah blah)
   {

   }

   public static blah blah lowestCommon2( blah blah )
   {

   }
}

For the efficient way, think about what you would do. and don't just say 'look at the two arrays and find the smallest common number', really break it down step by step. what do you actually look at, what do you compare, what decision to you make, and what do you do next?

10/19 - BPJ 15 Project - Overdrawn at the Bank
BPJ Lesson 15, second Project: Overdrawn at the Bank (due) at the END of the period, so TRY to set up as much of it as you can, but don't panic if you don't get all of it. This is about following the directions carefully, not figuring out a complex problem.

To submit, either append both classes into a single text file (preferred), or attach them to an email. Or make a JAR file.

- - -

To make a Java Archive file in BlueJ:
  Project-->Create Jar File
then tell it which class has the main() method and be sure to check Include Source.

10/18 - Blue Pelican lesson 15
Now look at Blue Pelican's introduction to objects.  Imagine if you hadn't read Head First first, and this was thrown at you cold.  Whoa, mama.
very dense lesson! CAREFULLY read Blue Pelican lesson 15. TRY to do the Diameter project (submit Circle.java) and the Exercises. 

10/15 - HFJ Chapter 3
Read Head First chapter 3.  Read it for yourself, not for me.  There's really great information that helps fill in the gaps and corrects the misunderstandings in the things you think you already know.  I can't collect the exercises in the back of the chapter because the answers are right there.  But TRY
 Be the Compiler,
 A Heap O' Trouble
 and Five Minute Mystery
There's nothing to turn in, but you're responsible for the content.

10/13 - HF Objectville reading
Read chapter 2.  Answer the questions (but not the programming exercises).  Submit paper, not electrons.
skip questions 8, 9, 13)(
<Chapter_02.doc>

<Chapter_02.pdf>

10/12 - heading over to Head First
As you're finishing up your array labs, also skim Head First, intro and chapter 1.  And over the next few days, do six  Array-1 Javabat exercises of your choice.

10/5 - array labs
[+1 week]
Read this:  http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
Skim Blue Pelican Lesson 18.
Do:  lab14_arrays in my Teacher Inbox.  Turn in the highest one you complete.

10/4 - reading: labeled break
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html

Read the above, paying particular attention to the difference between regular breaks/continues and labeled breaks/continues.  Also pay attention to how a loop is labeled and why the indenting is correct the way it is shown.

(If you must play with something, play with the args parameters, both from the command line (useful) and from BlueJ (awkward).)

10/1 - Blue Pelican 13 Exercise
Read Blue Pelican lesson 13.
Do 13 Exercise.

10/4 - test 2 - loops, switch
switch/case
while loops
for loops

9/29 - quadratic fun with all this new stuff
TRY to do all the stuff we talked about today.
You're going to make a program that takes 3 numbers as command line arguments.  Because args comes in as a String array, you'll have to parse them into doubles.  Rather than calculate the positive root (ignore the negative for now) in the main method, create a separate method that will take 3 numbers as parameters and return the positive root.  Print the result.  Capiche?

9/28 - planet weights with array
Modify your planet weights program (start with the integer version) so it uses arrays instead of the switch statement.  You should have an array of gravities and an array of planet names.  You should also print your planets list using a loop and a single short println.
Example of array usage:
   int[] numbers = { 3, 5, 6, 15, 8, 0, -8 };
   System.out.println( numbers[3] ); // prints 15

9/28 - planet weights with char
Modify your planet weights program to switch on a char instead of an int

9/27 - Blue Pelican lesson 10
Read: Lesson 10
Write:  Exercise 10
Do:  Project 10
 Rather than use their imaginary planets, make your program calculate weight on the real planets.  The gravity factor on other planets should be fairly easy to find on the internet.

9/24 - for/while worksheet questions
On the same piece of paper, answer the questions in 0928/forloopsworksheet and 0928/whileloopsworksheet1
<whileloopsworksheet1.doc>
<forloopsworksheet.doc>
[due in class]

10/2x - read: what would Gandhi do?
And in the news:
http://kotaku.com/why-gandhi-is-such-an-asshole-in-civilization-1653818245

9/x - appendix C + indent redo
1. Read BPJ appendix C.
 
2. Y'all really didn't take me at my word when I said the indenting had to be perfect, hmm? Congratulations. 40% of 5th period and 50% of 6th got scores of 2/10 for having more than 3 mistakes or otherwise not following the directions. Even sadder, only 8 people in 5th period had completely error-free indenting, and not a single diligent soul in 6th. Normally, you'd be stuck with that. But because it's actually really important that you indent your programs properly, I'm reluctantly going to let you redo these and go through the hassle of regrading them. But now they have to be absolutely perfect to get 6/10. One mistake takes you to 5 points. 2 to 4. 3 and why even bother?
Many of you ignored my direction not to use tabs and to leave in the unnecessary braces. Those counted as 2 errors each.

9/22 -      [+6 days]
0928/lab08_forloops
There are 7 labs that (supposedly) progress from easier (a) to harder (i).  Submit the hardest one you complete.
This doesn't mean if you can do the last one first, you don't have to do the rest.  We're going for quantity of practice here more so than quality.

0928/lab09_while_dowhile

There are 10 labs that (supposedly) progress from easier (a) to harder (k).  Submit the hardest one you complete.

9/21 - Blue Pelican 11 Project - Name Reversal

9/20 - Blue Pelican 11-12 Exercises
Do: 12 Exercises: 6-9, 13
Read: Lesson 11
    important concept: scope of variable
Do: 11 Exercises
Be sure to check your answers by typing and running the code.  But equally important, be sure to first try to solve the problems in your head and/or on paper.  You have to be able to think through your code and follow the values of your variables in order to be able to debug your programs..

9/17 - indent me!
It's absolutely critical that your code be readable.  Key components of that:
  1. commenting
  2. meaningful variable names
  3. consistent indenting

Some of you have turned in some real messes of indenting improvisation.  We're going to practice cleaning up two of them.  Yes, these are your actual submissions.

Using only a text editor (e.g. Notepad, Word) and not an IDE (e.g. BlueJ), clean up the indenting in the two mess files.  Use the example file as a guide.  To maintain column consistency, use only spaces and not tabs.  Adding carriage returns may also be necessary.

Since the dropbox can only take one file per student, submit both in a single long text file.

**WARNING:  Make sure you do these right.  They will be graded severely, because this should be easy (if tedious) work.  More than 3 errors and your score will be 2/10.

*Windows users:  If the attachments open as a single long line, try opening with Wordpad rather than Notepad.
(Long explanation:  Microsoft does text files different from Unix/Mac/everybody else. If you create a text file on Windows and bring it over to the Unix/Mac world, you'll see a weird "^M" meta-character at the end of each line, because Windows thinks it needs its own newline character in addition to the standard one.)

<indentExample>
<indentmess1.txt>
<indentmess2.txt>

9/17 - [test 1]
covers Blue Pelican Java lessons 1-9 plus 14

9/16 - projecteuler 1
Assignment:  projecteuler.net
  Use what you learned in the two practice exercises from yesterday to solve problem #1.   Don't just start coding blindly.  Think about how you're going to solve the problem first.
Other easier ones: #2, #6...

Also, study for your first test Friday. BPJ 1-9

9/15 - getting loopy
Practice 1: Modify your Blue Pelican Project 9 to loop.

Practice 2: Write a program that uses a while loop to print--NOT println--"your name is cool! " 30,000 times. Compile in BlueJ but run in the command line.
mod 1: slow it down with Thread.sleep()
    [see notes below]
mod 2: pad spaces at the end to make cool patterns or scrolling effects

 Also, study for your first test Friday. BPJ 1-9,14
- - - - -
Two ways to accommodate a possible exception with sleep:
try {
    Thread.sleep(milliseconds);
} catch (InterruptedException e) { }
or
public static void main(String args[]) throws InterruptedException { your program goes here }

9/14 - BPJ 9 project
Blue Pelican 9 Project
should be super short

9/13 - Blue Pelican lessons 8+9, odd Exercises

9/10 - intro to input
This assignment has an attachment, file 0c.pdf. It's Powerpoint slides.  Carefully read slides 1-10, skim 11-20, read 21-22, skim 23-30.

Read Blue Pelican lesson 7.

Do Blue Pelican 7 Project: Going In Circles.

(Optional #1: Read slides 29-30.  See attachment GuiHelp.java for an example.)

(Optional #2: If anyone besides Rebecca and Chris has been wondering why you get weird rounding errors with floating point math, take a skim through http://mindprod.com/jgloss/floatingpoint.html and http://www.ibm.com/developerworks/java/library/j-jtp0114/  It's very good stuff to know.)
<0c.pdf>
<GuiHelp.java>

9/9 - Blue Pelican:  read Lesson 6.  do 5 Exercise.

9/8 - Blue Pelican 5 Project
Read lesson 5 carefully, paying particular attention to the casting. Code the 5 Project. (And fix 4 Exercise and 3/4 Project from yesterday.)

9/7 - Blue Pelican 4
Read: Blue Pelican Lesson 4
Write: 4 Exercise
Code: 3+4 Projects
 Good practice says a program/method/class does just one thing and one thing well.  Flaunt bad practice and write a single program that combines the output for both the 3 Project and the 4 Project.

9/3 - Blue Pelican lessons 2 & 3
Skim Lesson 1.
Read Lesson 2.  Do 2 Exercise.  (on paper, minimal answers are fine, no need for complete sentences unless you want to.)
Read Lesson 3.  Do 3 Exercise.  (but not 3 Project yet)

Set up your flash drive for Java. 
- In addition to command.com, copy the JDK folder from your home computer (since you don't have access to the C: drive at school) to your flash drive.  And if you haven't already, download BlueJ (bluej.org) and also copy that onto your flash drive.
(Mac folks: You'll want the PC version of BlueJ on your flash drives, so you should probably wait till Tuesday to copy it off your friend's flash drive.)
- You'll also want your Blue Pelican textbook PDF.  And I've been told that you can find electronic copies of the Head First text floating around, not that I'd actually suggest any such blatantly illegal behavior.  But if you were to stumble across such a thing, there are at least two versions, and the smaller file seems to be a cleaner copy.  Or so I've been told.
- other:
Not necessary for this class, but things that you may find just useful to have on a flash drive:  cmd.exe, a web browser, an office suite...a light PDF viewer like Foxit...  And flash drives do easily get lost, so consider them consumables, and do regularly back up files that you can't easily replace i.e. not applications that you can redownload, but your documents that you created.

Also also, if you had trouble with the command line stuff, take a little more time to try to get it to work.  You will need it...not very often, but occasionally.

9/2 - Hello, ASCII art
1. Install the JDK
  (Mac folks, you probably already have it.  Run "javac -version" to verify.)
  a) Download the JDK from oracle.com
  b) Add the JDK directory to your path
    (http://www.java.com/en/download/help/path.xml)
    (http://www.oracle.com/technetwork/java/javase/install-windows-189425.html section 4)
    (http://www.cs.princeton.edu/introcs/15inout/windows-cmd.html for Win7)

2.  Hello, world.
  http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
  Use "java" and "javac" from a command prompt to compile and run.  (Or if all else fails, you can resort to BlueJ (bluej.org).)
  (Note: Contrary to their Save As instruction #2, do *not* include quotation marks.)

3.  Modify your program to draw an animal or some other ASCII art
  To print special characters, you may need to precede them with a backslash ("\")

4.  Submit your .java file via drop box on assignment page in Schoolloop
  (Assignment page may no longer exist? If you see this as an expanded calendar item, in the upper right here should be an option to Submit work from your Device.)

8/31 - Blue Pelican 14
Download the Blue Pelican Java text from either my Teacher Inbox or the "locker" on the AP Comp Sci Schoolloop page. Try the odd Exercise questions in Lesson 14 (except #5, 9, 25)

Note: You should at least skim the lesson reading. But I really dislike their method of converting decimal to binary. The way that I like better is described here as "Method 2 of 2": http://www.wikihow.com/Convert-from-Decimal-to-Binary (Ignore "Method 1", as it's the same as Blue Pelican.)

8/30 - syllabus, donation, history
Get course overview and donation letter signed
Read http://www.computersciencelab.com/ComputerHistory/History.htm





summary:


6/7/10        final project        1       
5/10/10        final project proposal        1       
5/4/10        AP CS TEST        1       
5/3/10        final AP review        1       
4/30/10        Javabat AP-1 x 7        1       
4/27/10        AP practice exam - FRQ 3 GW        1       
4/26/10        GridWorld review        1       
4/21/10        2009 FRQs        1       
4/20/10        frq2008-1 and 2008-2        1       
4/20/10        ap09 multiple choice        1       
4/16/10        frq2008-4        1       
4/14/10        test 6        1       
4/13/10        review: BPJ Contest Type Problems 38, 39, 45        1       
4/13/10        review: BPJ Contest Type Problems 43, 41, 51        1       
4/12/10        BPJ 51 Binary Search        1       
4/2/10        BPJ 48 flow chart        1       
3/30/10        BPJ 45 Comparable proj 1        1       
3/29/10        BPJ 17 exercise: String methods        1       
3/26/10        frq2006-3        1       
3/23/10        BPJ 41 proj: Multi Key Sorting        1       
3/17/10        BPJ 41 insertion quick merge        1       
3/16/10        BPJ 41 bubble + selection sorts        1       
3/15/10        BPJ 39 exercise: Big O        1       
3/11/10        frq2006-2        1       
3/10/10        towers of hanoi        1       
3/9/10        BPJ 40 Project: ModFib + Javabat fibonacci        1       
3/8/10        Blue Pelican 40 Exercise: recursion        1       
3/4/10        Stockpile + ArrayList glitch        1       
3/3/10        Blue Pelican 38 Project: Linear Function interface        1       
3/2/10        Blue Pelican 38 Exercise        1       
3/1/10        Blue Pelican 22 Exercise        1       
2/24/10        GridWorld review questions        1       
2/23/10        BPJ 43 Project: Big Bucks        1       
2/22/10        BPJ 43 + 21 Exercise        1       
2/17/10        Battle Critter        1       
2/10/10        GridWorld Qritter qrestions        1       
2/8/10        GridWorld nitty gritty        1       
2/3/10        BoxBug        1       
2/1/10        enter gridworld        1       
1/15/10        Scale 'Em Up or Down        1       
1/12/10        Double 'Em to file        1       
1/11/10        Double 'Em from file        1       
1/8/10        Double 'Em Right        1       
1/6/10        mostly review        1       
12/18/09        intro to graphics        1       
12/14/09        BPJ 35 Project: Matrix Multiplication        1       
12/11/09        BPJ 35 Exercise        1       
12/8/09        test 4        1       
12/7/09        HF reading: interfaces        1       
12/3/09        HF serious polymorphism reading 1        1       
12/2/09        roshambetter        1       
12/1/09        roshambo        1       
11/23/09        BP 36B + extend Robot        1       
11/18/09        FamousPoets        1       
11/13/09        intro to inheritance (HF+BP)        1       
11/12/09        array practice, dip into Objectville        1       
11/10/09        Blue Pelican lesson 19        1       
11/9/09        battleship / Head First chapter 6        1       
11/3/09        Head First chapter 5        1       
11/2/09        plan for battle(ship)        1       
10/26/09        Robot + HF Ch 4 questions        1       
10/21/09        fraction objects        1       
10/20/09        BPJ 20 static        1       
10/19/09        HF4 + smallest common number        1       
10/16/09        HFJ Chapter 3        1       
10/14/09        HF Objectville reading        1       
10/13/09        BPJ 15 Project - Overdrawn at the Bank        1       
10/12/09        Blue Pelican lesson 15        1       
10/9/09        array labs        1       
10/6/09        reading - labeled break        1       
10/5/09        Blue Pelican 13 Exercise        1       
10/2/09        lab08_forloops        1       
10/2/09        lab09_while_dowhile        1       
10/2/09        test 2 - loops, switch        1       
9/29/09        for/while worksheet questions        1       
9/28/09        planet weights with char        1       
9/28/09        planet weights with array        1       
9/24/09        Blue Pelican lesson 10        1       
9/23/09        Blue Pelican 12 Project - Name Reversal        1       
9/22/09        Blue Pelican 11-12 Exercises        1       
9/21/09        indent me!        1       
9/18/09        projecteuler 1        1       
9/16/09        getting loopy        1       
9/15/09        Blue Pelican 8+9 Exercises        1       
9/14/09        intro to input        1       
9/11/09        Blue Pelican - 5 Exercise        1       
9/10/09        Blue Pelican - 5 Project        1       
9/9/09        Blue Pelican lesson 4        1       
9/8/09        Blue Pelican lessons 2 & 3        1       
9/4/09        lab oa.syntax_output