Sunday, 6 February 2011

Grid World Page 12

1. What is the role of the instance variable sideLength?
sideLength calculates how many steps BoxBug travels before it turns 90 degrees right.(clockwise) 
2. What is the role of the instance variable steps?  
Like the name of the variable indicates, it counts the amount of steps the BoxBug has done since last turn.Every turn, the variable resets, or goes back to 0 and counts until the next turn. 
3. Why is the turn() method called twice when steps becomes equal to sideLength?  
A single turn() method would turn it by 45 degrees.So twice calling it will make it do a 90 degree turn. 
4. Why can the move() method be called in the BoxBug class when there is no move() method in the BoxBug code?  
All the methods from the BoxBug class extend to the Bug class so the move() method should also be available in the Bug class.
5. After a BoxBug is constructed, will the size of its square pattern always be the same? Why or why not?
No the size of the square pattern will never change.There is not method to change the size of the square pattern so it will remain the same as default. 
6. Can the path a BoxBug travels ever change? Why or why not?  
Yes the path will always change. Even if the amount of steps is not sufficient, the bug will change its direction at every single corner or touching the boundary. 
7. When will the value of steps be zero?  
It changes to zero when it has reached the right amount of steps or it meets a corner of the grid.

Grid World Page 6 + Page 8

1. Does the bug always move to a new location? Explain.
If there is rock infront or bug reaches corner/boundary of the grind, it turn clockwise. 
2. In which direction does the bug move?
The bug will always move straight by default but with every turn or corner the direction of straight changes.
3. What does the bug do if it does not move?
Clockwise
4. What does a bug leave behind when it moves?
A flower.
5. What happens when the bug is at an edge of the grid? (Consider whether the bug
is facing the edge as well as whether the bug is facing some other direction when
answering this question.)
Clockwise, when bug hits the edge. 
6. What happens when a bug has a rock in the location immediately in front of it?
Every edge the bug turns clockwise, the rock is therefore also treated like an edge and it turn clockwise. 
7. Does a flower move?
Nope
8. What behavior does a flower have?
Flower slowly fades to black. 
9. Does a rock move or have any other behavior?
Rock is always stationary.
10. Can more than one actor (bug, flower, rock) be in the same location in the grid at
the same time?
Nope, only one object at a time. 

PAGE 8
1. Test the setDirection()   method with the following inputs and complete the table, giving the compass direction each input represents.


degrees
compass direction
0
North
45
NE
90
E 
135
SE
180
S
225
SW
270
W
315
NW
360
 N
2. Move a bug to a different location using the moveTo() method.

In which directions can you move it?

How far can you move it?

What happens if you try to move the bug outside the grid?
The moveTo() takes the co-ordinate of the bug into consideration, which is the row and the column where the bug is.We can place the bug anywhere in the grid, according to the coordinates. If we try to place it outside the grid, we will get an error. 
3. Change the color of a bug, a flower, and a rock.

Which method did you use?
setColor() is a method of the superclass. It is implemented into all the classes and can be used to change the colour of all the objects inside the grid. So the stone, the bug the flower, their colours can be changed using this method.
4. Move a rock on top of a bug and then move the rock again.

What happened to the bug?
There is no more bug. This is because their is only space for 1 bug to fit into each space of the grid. When we try to place a bug on top of a place of an existing bug, the previous bug will be deleted and the new bug will take its place.

Sunday, 30 January 2011

Sudoku and Java Fundamentals

This week was actually quiet long it seems. TO start of, we worked on something new called the Sudoku game. Its a number puzzle game which requires great deal of algorithms if you are familiar with the game. I was not so it was not the easiest thing for me to get through. SO I worked with Gershon in class on that project. Well basically our first task was to create a 9x9 board and completely randomize the 81 set of numbers so that they do not end up next to each other. And we had to set up a method of count which would indicate what are the chances of randomly throwing numbers on the board, without any form or use or algorithm and achieve a fully solved Sudoku board. The chance of that happening... when Gerson tried the count went up to 7 million.. yes 7 million and the count still did not reach a number so we had to shut down the machine. But the Sudoku board is very premature at this moment right now. All though all the numbers might be different in each row and column with no repetitions, they might not satisfy the criteria for unique set of numbers in each 3x3 box. So we need to work on that because that is a major issue. Any ways that was the first project.
Over the weekend we were supposed to answer 24 multiple choice questions from the book. It was not easy because I did not know what hexadecimal digits are so I had go through the review but I understand it completely now and I feel confident about it. I got 22 multiple choices right but it took me a while because I had to go through the review.

Sunday, 23 January 2011

One Dimensional Plus 2D Arrays

So for the weekend, which was very busy, because of Hockey Marathon and all, we were expected to answer 37 questions of multiple choice from the book. I got 30 out of 37 multiple choice right but in general there was little trouble in understanding the concepts in the book, so that was a plus side but they took a while because they were long and time consuming, not that they were hard but you need a lot of time to figure out and work the questions out. Also on Sunday, when I was tired as hell, I tried to brush up on some Recursion problems in JavaBat and I did like 8 JavaBat's which was good.

Sunday, 16 January 2011

Searching and Sorting Exercise

So for the weekend, we had to complete 33 multiple choice questions. I understood them all well, but it took me nearly 2 hours to do them, because they got a little confusing and I took brakes in middle. Also for the ArrayDemo exercise that we had been working on throughout the week, but I started doing them on Friday when i got back home. I got most of the methods done.But I am still getting used to working with the two Sorting Methods, because they are quiet confusing at times. Also we talked about BinarySearch in class, which is a Search method, which made clear sense. But in class when Gerson started explaining about the whole move method and stuff with the coding for the Towers of Hanoi, just looking at the code made sense, but the algorithm really got to me because I could not get the block to physically move inside my head. But the code looks much simpler. So that is something I need to work with before the test. And also I have like 4 methods of the ArrayDemo which I will complete by Monday night. I just solved like 4 JavaBat recursion questions so I need to work on that aswell.

Sunday, 9 January 2011

Recursions & Diagnostic Test

Over the weekend, I got the chance to start working on recursions on  Java Bat. I needed some external help, so I asked Uri T. for some help, but it was alright. I also got to work on 21 multiple choice from the Diagnostic Test in the Barron's Book. Easy to say, it was not that fun. I got 14 out of 21 right. It was actually quiet challenging and i tried looking at the explanation and it varied, for some I understood my mistake but for the others, it just confused me more so I left the questions. Especially questions 12, 14 and 20, I remain clueless about. I figured that I had problems with questions where there can be more then 2 possibilities to the answer like in question 12 and you have to verify each option one by one. I really need to practice on those questions. Also, question 18, which deals with the output being a numerical value, I could not comprehend the methods and thus I messed up. Overall, its was alright. Further I took a brake from the test and went to Java to work on Recursions while i was taking a brake. I think I understand string-recursion related problems well, so I should be able to do them smoothly.  

Wednesday, 1 December 2010

WikiLeaks ..Something Interesting.

This is a video about Wikileaks. It is strongly gaining popularity because of its controversial issue. The growing adolescents have to be aware of this growing issue.

http://www.ted.com/talks/julian_assange_why_the_world_needs_wikileaks.html