Articles in the 2009 AP CS A Category
2009 AP CS A »
Nice work on the classes, arrays and ArrayList quiz! I loved reading the extra credit, as usual!
The rockin’ coder loves Java
His codes are hotter than lava
He writes code faster than the speed of light
When it compiles the whole world is in flight
The gangsta coder makes his way
Writing lines of code to save the day.
He compiles often and knows to debug;
this rockin’ coder’s a computer thug!
I’m from 8 mile
Where only the hardest compile
We always do it in style
Because we ain’t had cast for a while
Don’t hit me on the nextel chirp
I …
2009 AP CS A »
GridWorld is your AP case study. It’s a great opportunity to get familiar with a larger code base and see an example of well-designed object-oriented code at work. I hope you’ll have fun working with it, too!
Getting the files
Download a zip file of the Gridworld code.
Extract all the files from the Gridworld archive into your computer science folder.
JGrasp
You’ll need to add the Gridworld jar file to your CLASSPATH. Follow these images:
Eclipse
1) Create a new project
2) Right click on the project name in the package explorer
3) Click on …
2009 AP CS A, 2010 Spring Creative Computing 1, 2010 Spring Exploring CS »
There are some amazing books out there related to computer science concepts. Reading books like these has really gotten me excited about learning and I would like you to have the opportunity to dive in and see some of the amazing ideas out there.
In fact, I care enough about this that I am offering 10 extra credit points for you to read one of these books, discuss it with me for about 10 minutes and write a short blog post about it. I don’t want a book summary, I don’t want …
2009 AP CS A »
As always, many thanks to Stuart Reges for letting me mercilessly steal from his excellent materials!!
You will need two support files: ShoppingMain.java and ShoppingFrame.java.
This assignment will allow you to review defining Java classes as well as the use of ArrayLists. It will hopefully also give you some insight on how larger, graphics-based programs are designed and built. Your task will be to write a set of supporting classes for a simple shopping program. I’m providing the GUI code (Graphical User Interface) that will provide the “front end” to the …
2009 AP CS A »
Check out the ArrayList slides to make sure you understand how to use all of the methods and to make sure you understand the generic syntax.
We’ll just spend today and a little of Wednesday doing some mechanical exercises to get you used to the syntax and then dive into a larger project.
Negative Integers
Write a method that prints all negative values in an ArrayList of Integers. Use an enhanced for loop.
Max Length
Write a method maxLength that takes an ArrayList of Strings as a parameter and that returns the length of the longest string in …
2009 AP CS A »
Of course, the full ArrayList specification is available with the rest of the Java documentation. Though I encourage you to explore all of the capabilities of ArrayLists, you will only be responsible for the following methods:
Method name
Description
add(value)
adds the given value to the end of the list
add(index, value)
inserts the given value before the given index
clear()
removes all elements
contains(value)
returns true if the given element is in the list
get(index)
returns the value at the given index
indexOf(value)
returns the first index at which the given element appears in the list (or -1 if not found)
lastIndexOf(value)
returns the last …
2009 AP CS A »
With the introduction of Eclipse as the primary IDE for AP CS, Javadocs becomes a useful tool, unlike in jGrasp, which does not utilize Javadocs.
The usefulness of this can be seen by hovering one’s mouse over such things as objects (e.g. a Scanner), which will provide information.
This can be implemented in personal methods, constructors, etc. by /** then enter (eclipse/java does most of the work for you), followed by typing whatever data is needed. An example for the following method “encodes()”
public boolean encodes() {
// implementation omitted
}
Javadocs can be used for this …
2009 AP CS A »
An nxn matrix that is filled with the numbers 1, 2, 3 … n² is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value.
Square
Write a class Square with a constructor that takes in an integer matrix. You will write the following instance methods:
boolean method to check whether each number 1 – n² occurs exactly once
int method that computes the row sum
int method that computes the column sum
int method that computes the diagonal sum
isMagic method that …
2009 AP CS A »
As I mentioned really briefly, System.out is an object of type PrintStream. Check out the Java documentation to convince yourself that all PrintStream objects have print and println methods.
In order to print out to a file instead of to the console, all we have to do is have a PrintStream object that connects to a file. If you look carefully at the constructor list, you’ll see that there’s one that takes a file as a parameter. Bingo.
So here’s what you do. You build a File object …
2009 AP CS A »
I think creative expression is really important.
Check out these amazing extra credit drawings AP students did… 2009 AP CS programming drawings



