Monday, February 28, 2011

Grid World

Okay class, Today's lesson was pretty simple:
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!!!!

Today in class we studied for the test tomorrow. We didn't really learn anything new from before execpt arrays & array list. It helped a lot I understood it way more & I should do good on this test.

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.

Hey there fellow classmates! :D
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!

Monday was a very productive day! We started off with a do now, in which we had to return true if the number One is greater than the number of 4 's. I felt the class understood the problem to a certain extent, Ive realize that many people enjoy the Do Now,but many students in the class need a further breakdown to understand and write the code themselves.
After the Do Now we proceeded to work on CowPie program generating ideas of how to form the program i.e. the methods needed and if constructors would need to be present in this program.

Methods
________
initializeBoard();
hideThePie();
giveHint(int guessRow,in guessCol)
toString()

Also, Do not forget to fill out the survey below for the chance to win a very enticing chance to have the Computer Lab open during your period!!!!!!!!!!!!!!. See Below For More Information

|
|
|
|
|
V

Friday, February 11, 2011

(February 10, 2011 ) APCS Class

Hello, APCS Students. Today we have recieved the Books for REACH, make sure you take them with you Saturday morning. Today's lesson (do now) we briefly and smoothly went over using loops to edit our (tic-tac-toe program). We found out which loop is better to use when you know how many times(the program) will go over the loop = for loops. For loops that can have an unknown amount = while loop. We also continued working with Arrays to expand our knowledge on creating Boards. In the upcoming monday we need to do and finish a code (Hunt the Cowpie , Yuck! ) this game will set random points on where the CowPie(or as we would like to call it . Cow Dong) is located. It'll have the user input a set of points being Rows and Columns and ask for guesses. The assignment to me is understandable. Since the code will be nearly done for us, and work in class together we will just have to add a few methods and functions (this is where the Challenge comes). EVERYONE should start fiddling around and add on to the code.

Important Notice from Mr. Jacoby, Change of plans : we will be working on the code Monday!!!

Read Chapters 1 and 6 in our new Barron's review guides.
Both chapters: Complete all ODD problems the end-of-chapter multiple choice review section.

Don't forget: REACH Saturday morning @ Baruch College, 8:30 am!!

Wednesday, February 9, 2011

Today's Do Now:
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

Today's Do Now:
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

Today we reviewed our new class blog. This blog is mainly about the students summarizing what they had learned that day. Mr. Jacoby will be sending you invites to the class blog using the emails that you had submitted on survey. Every Monday a schedule will be released showing who will be responsible for posting on the blog for that week. We also reviewed our final exams. Congrats to Jonathan for getting the highest score. If you want to see the corrections for the finals and today's lesson click here. That's pretty much it for today.

Julio

Friday, February 4, 2011

Welcome to the AP Computer Science blog!

Welcome everyone. This will be your blog, a daily summary of what you learned in class (and/or what confused you). The more work you put into it, the more useful it will be for you and your classmates, and the cooler it will look. Participation is voluntary, but if you volunteer to do it, please be diligent and make sure you post useful information.

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 :)
Remember that you're writing in HTML, so if you need help, try googling "HTML help".  When posting code, you should switch to the pure HTML editor and use proper tags before (<pre>) and after (</pre>) your code.  This way it will look all nice and indented.  For example:
for (Student s : apcsStudents) {
  if (s.isVolunteerBlogger()) {
    s.writeBlogPost();
  }
}

Good luck, and ask for help if you need it!

Mr. Jacoby