The students' perspective from A. Philip Randolph's AP Computer Science class.
Thursday, March 24, 2011
Scope
Fibonacci
We also learned the fibonacci code and we did test preparation.
In the fibonacci code when using blue jay the computer recalculates the whole sequence to get the next value of the fibonacci code.
They add the first two index's to get the next index then recalculates all the index's to get the next sequence of the set.
Tuesday, March 22, 2011
Recursion and Palindromes
recursion
just trying to blog
What we learned in class today was about recursion, but it was at the last 10 minutes of class because all of us were doing the jumper project. From Mr. Jacoby recursion is a strategy for solving problems by
repeatedly reducing them to simpler problems.
For example: factorials
5! = 5 x 4!
4! = 4 x 3!
3! = 3 x 2!
2! = 2 x 1!
So from what i got the lower u go the more u can understand what is the answer.
Also that the repitition of it would eventually end it up being easier to do by that every time it recur it would repeat and then the simplest form and then from there go forwards then u should be able to get your answer.
Recursive problems are broken down into two cases
line 1. The base case: the simplest case where no computation is necessary.
line 2. The recursive case: everything else - brings us to closer to the base case. It simplifies or reduces the problem.
public int factorial(int n) {
line 1: if (n == 0) return 1;
line 2: return n * factorial(n ‐ 1);
}
All loops can be written recursively though its not a good idea!
Tuesday, March 15, 2011
INTERFACES!!!
Monday, March 14, 2011
computer science 3/14/11
Today's lesson in APCS was based on the pi day contest that the whole school goes through held by all of our known math teacher's Levy, Jacoby, Reisman, and others.
From our class, Omar managed to memorize 93 digits of pi (for what I dont know -__- lolz).
We also installed Eclipse, which like Blue Jay, is another coding "environment" for java. To install Eclipse, all you have to do is unpack the zip file download in the directory you want. When you unzip the file, it creates a subdirectory called "eclipse", with other subdirectories under that.
We got our tests back today, and you're like me who failed, you shouldn't worry about it to much because Jacoby curved the grade. So, take the grade you got on your test and find the square root of that and times it by 10, and that is your grade. Still failed...well try harder next time. =D
Tuesday, March 8, 2011
Test Review 2 plus some Blogspot fail
Firstly, today was super brief (lucky me) and we were refreshed on how an ArrayList works.
for example in ArrayList named List... Do you know what
List.add(x) means?
Well cause ArrayLists are more "Complex" than regular arrays so they have many different codes that remove and add variables to the Array.
Of wait getting ahead of myself now :)
List.add(x) meant that in the ArrayList of List , x was added/implemented to the end of the list. Although Mr.Jacoby didnt further explain this, to the end of the ArrayList did not mean it would literally go to the "end" but to the next space after a variable, if there was no variable inputted and x was the first, then it would be in the first.
Seems vague but most things are.
We were also refreshed on how to add a variable to an index in the ArrayList the code would be the same, a code demonstration would work out better...
List.add(1,5) <=This implements the second indeces, as we have to start counting by one, with the variable 5.
One thing what we have to keep in mind is that when an index is already being used and you add another variable to that indeces using this code, the remainder is shifted up the ArrayList.
so...
List{5,7,4,1}
List.add(1,3) <=the ArrayList will automatically shift the 7,4,1 up and the new array will be List{5,3,7,4,1}.
I NEED to finish off as I'm scared my blog will, or is taking up the webspace xD.
Extra notes>>>>>>>[ ] brackets means what you're declaring is an array,and ArrayList get larger by copying their current variables into a larger arraylist so the ArrayList space is endless and I'm guessing this wasn't so brief after all...-SANTIAGO
Monday, March 7, 2011
Look at that, test review (And random Tidbits of stuff from Fern :D )
Sunday, March 6, 2011
REACH Session #2
Friday, March 4, 2011
Polymorphism and abstract classes
}
a will be an object. The object can be Animal, Dog, or Cow. So if the object is cow, it will therefore call out "wassup?" If the Java virtual machine did not know the object, it wouldn't have done anything.
.....
An abstract class declares fields and abstract methods so that its subclasses can use them, but it represents an abstract idea that can't itself be instantiated. An abstract class need concrete subclasses to implement abstract methods. Concrete subclasses are specific. For example, an abstract class would be Car and a concrete subclass would be Move.
- I tried to explain as best as i could and i hope this helped.
Be sure to do Homework 18 (due Monday): GridWorld pg. 15 # 4 (dancing bug!!)
Reminder: We have REACH tomorrow!!....Note: The GridWorld assignment will be bonus for students who attend REACH.
Wednesday, March 2, 2011
Inheritance and GridWorld Actors
Monday, February 28, 2011
Grid World
1) By now everyone should have installed Grid World on their computers in school( and at home). For those of you who have already installed it, i hope you took the initiative to observe and experiment with GridWorld. I hope that you took note of the actors(bug, flower, or rock) and played around with the methods that you can invoke on the actors.
Mr. Jacoby also taught us a little about subClasses and parentClasses and childClasses. If you need extra help with them you can turn to chapter 13 of our java concepts test book where you will find everything you need to know about constructing subClasses.
* Don't forget the homework that is due on Wednesday
Read from pages 10-12 and answer exercise questions 1 and 2 on page 13.
** For those of you who did not complete the homework that was given over the break due to installation problems I hope what we did in class has helped and you will be able to complete it as soon as possible.
Wednesday, February 16, 2011
TEST REVIEW!!!!
For Array :
Creating,Acessing, & Updating
Algorithms (search,copy,etc.)
For ArrayLists :
Creating,Acessing, & Updating
Algorithms (search,copy,etc.)
Minor topics :
Wrapper Classes ( Integer,Double,Long)
Generic Types(ArrayList
Many simple stuff but if you study today & stay focused you should do good on the test. So I am going to keep studying. GOOD LUCK TOMORROW :]
Tuesday, February 15, 2011
Programming with a side of Cow Munchies.
What we did today was continue on our lovely Cow Pie game, in which you..er..hunt a cow's sweet droppings for the day. The game is kind of like a super simple version of mind sweeper, all you have to do is guess a row and column, and hopefully, in this case, you find Winne the "Pooh" . Also, some of us, including me >.<, had a little trouble with the Random class, so here's how to do it: (you can also look online at http://web.aprchs.net/jacoby/mj2x_2011).
1) Import the the Random class, java.util.Random
2) Construct a new Random generator, Random generator = new Random();
3) make number generators for int pieRow & pieCol,
int pieRow=generator.nextInt(ROWS);
same for pieCol, just use COLS.
The link to the code is at the bottom of the blog. Us super and awesomely smart children have to revise certain parts of the "Hunt Cow Pie" code the J - Man left for us, which is due tomorrow. So have fun finishing the rest of the code, and goodnight!
link to code:
http://web.aprchs.net/jacoby/mj2x_2011/feb14huntthevalentinescowpie
P.S. Don't forget to vote in the poll so we can decide which pd. to use it! //...vote for pd. 7 >:D, jk
link to poll --> http://web.aprchs.net/jacoby/mj2x_2011/newpollcomputerlabtime
P.S.S Remember to study for the exam on, Thursday! <(^_^)>
Monday Blog Report!
Friday, February 11, 2011
(February 10, 2011 ) APCS Class
Wednesday, February 9, 2011
1. Download the files TicTacToe.java and TicTacToeTester.java from the class website.
2. Add a Method to TicTacToe that counts the number of empty board locations.
Solution :
(Note: The new method must not be typed with in another method)
/**
* What this Method does is it counts the empty board locations, by declaring a new
* variable called count set to equal zero, and as the program advances it moves
* along the empty spaces and increases the value of count as it passes these empty
* spaces but if the space is occupied the value of count stays the same until it
* the method comes across a another empty board space.
*
*/
public int countEmptySpaces()
{
int count = 0
for ( int row = 0; row < ROWS; row++) {
for (int col = 0; col < COLUMNS; col++; }
if (board[row][col].equals(" ")) { count++; }
}
}
return count;
}
02/08/2011
Give an array of ints length 3, return a new array with the elements in reverse, order, so {1, 2, 3} becomes {3, 2, 1}
reverse3({1, 2, 3}) --> {3, 2, 1}
reverse3({5, 11, 9}) --> {9, 11, 5}
reverse3({7, 0, 0}) --> {0,0,7}
public int[] reverse3(int[] nums) {
int[] reversed = new int[3];
for ( int i = 0; i < nums.length; i++) {
reversed[i] = nums[2-i];
}
OR
reversed[0] = nums[2];
reversed[1] = nums[1];
reversed[2] = nums[0];
Then we went over to the Final exam, the last question before the bonus (#15)
(refer to mj2x-05-reviewFinal.pdf )
solution:
public static void printInvite( String name, String gift) {
System.out.println("Dear" + name);
System.out.println("Thanks for the" +gift+ "you...");
System.out.println("I really hope...");
System.out.println("Love, me.");
}
public static void printInvitations() {
printInvitation("Abuelita", "socks");
printInvitation("Uncle George", "rocks");
}
Bonus Question:
int pow;
for (int pow = 0; Math.pow(2,pow) < n; pow++)
{}
pow--; //*at this point is the largest power of 2 while less than n
String results = "1";
Then we went over the previous homework assignment: mj2x-03-arrayLists-p9.pdf
(The answers should be posted on the website)
R8.16
(a) do a "for" loop. You can return false when they do not match but you can't return true until the very end
(b) a "for" loop in which you send the values of one array to the other.
(c) go to every single element and send it equal to 0
(d) use list.clear OR while list.length > 0, remove all elements
R.17 True or false?
1- True
2- True
3- False *subscripts and indices mean the same thing*
4- True
5- True
6- false
7- True
8- False
http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
Brief introduction to Two-Dimensional Arrays (refer to Today's SMARTboard notes)
Why do we want to use them? Let's say we wanted to make a program to play a tic-tac toe game
Computer scientists would visualize this as being an array in two directions: rows and columns
You would start at 0 on both sides. It's like playing that 80s game Battleship
If you wanted to talk about a specific spot, you would say (0,1)
-->board[0][1]
How would you actually DECLARE these things?
Declaring a 2D Array
int[][] board = new int [3 which is the size of the rows][3 which is the size of the columns];
To know what's an X and O
final int X = 1;
final int O = 2;
final int EMPTY = 0;
You'll need 2 loops for this dimension, going row by row. Similar to what we did for the TimesTables assignment
for(int row = 0; row < 3; row++){
(int col = 0; col <3; col++){
if(board[row][col]==EMPTY)
System.out.print(" ");
else if (board[row][col]==X)
System.out.print("O")
}
}
System.out.println();
}
The HW is due on Thursday. Refer to website. It's going to be about Tic-Tac-Toe
We'll have time in class to do them Wednesday as well.
Bye!
Monday, February 7, 2011
Aim5: Review blog, final exams, & HW
Julio
Friday, February 4, 2011
Welcome to the AP Computer Science blog!
Guidelines
- Start by looking back at your notes and trying to remember what were the BIG ideas of the class.
- Try to write in a conversational tone, using your own words, so that people who missed class can learn from your post.
- If there was a common mistake addressed in class, that would also be useful to mention.
- Feel free to copy and paste pictures from the class notes that I post on the class website.
- Please use the "preview" button before you publish your post :)
for (Student s : apcsStudents) { if (s.isVolunteerBlogger()) { s.writeBlogPost(); } }
Good luck, and ask for help if you need it!
Mr. Jacoby