Sunday 27 March 2011

Post on packet given last class

I got 6 question correct out of the 8 multiple choice.

I do not completely understand all my mistakes so I hope to go over them in class.

Regarding Codingbat:
I have code for several questions however they either wont compile or do not return a "all correct" message
I will ask Gershon or Elhanan for help on Monday

Tuesday 22 March 2011

Gridworld Practice Exam

I found the packet quite helpful seeing as it cleared some things up for me regarding Gridworld.

I got 5 correct out of 6 and found most of the question quite easy.

There was nothing in the packet which I did not actually understand. I even understood the question i got wrong. However, I find the level of the packet simpler than all the test being given in class.

Sunday 6 March 2011

Last Barrons Chapter

I did very well on the multiple choice questions on this chapter.. (only 3 wrong)

I understood my mistakes, they were mostly on the theoretical questions regarding programming

I understand this chapter very well and I feel very confident about it

Monday 28 February 2011

By 8:00pm Monday 28th in your blog

1. Barron’s Review (Some Standard Classes)
How did you do on the multiple choice questions?
Did you understand your errors?
What do you not understand?
2. Comment on, or proposal for GridWorld project
3. Implement caterpillar
4. 3 coding-bat problems
1)
 How did I do?
I got 17 questions right out of 22. I noticed that the easiest questions for me were those about strings.

Did I understand my errors?
I understood most of my errors yet some questions still confuse me especially regarding the Math class and the Random class.

What do I not understand?
I understand most of the material and I am sure I will get better with practice. I am a bit confused about the indexOf method and how it functions.

2)

 After going over the packet this project seems very interesting. I have sort of understood how the project should work and I understand the methods and purposes of each actor in the project. I am not sure what I am suppose to do by now but since you said to only comment at the moment, I shall wait for further instructions.
 I can already assume I will need quite a bit of help throughout this project. Hopefully, the packet is helpful enough so I will be able to work independently most of the time.

3)

My caterpillar class does not compile, I am also not sure that if it will compile it will work as intended. Hopefully I will be able to fix and understand my caterpillar implementation during our class.

4) I was not able to do any Array 3 or String 3. As you told me, I spoke to Gershon and he is more than willing to help me. However, he was not free today so he will assist me tomorrow. Thus, I will only have the codingbat exercises ready by Tuesday. Please take this into your consideration. Thanks in advance.

Thursday 24 February 2011

Barron’s Review (Gridworld)

How did you do on the multiple choice questions?

I got most of the multiple choice questions correct (8 wrong). 
Most questions were quite simple were not difficult for me.


Did you understand your errors?

I understood almost all of my errors, most of them were simply caused by careless mistakes and reading the instructions incorrectly.

What do you not understand?

I am having a bit of trouble with some of the Critter class and how the critter acts. Other than that I feel quite confident with the Gridworld material

Thursday 17 February 2011

TwisterRunner Excersise

This is my twister class.


import info.gridworld.actor.Bug;
import info.gridworld.actor.Actor;
import info.gridworld.grid.Grid;
import info.gridworld.actor.ActorWorld;
import java.awt.Color;
import java.util.ArrayList;
import info.gridworld.grid.Location;

/**
* Write a description of class Twister here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Twister extends Actor
{
 public Twister()
 {
           setColor (Color.black);
        }
  
        public void act()
        {
                destroy();
                 move ();
        }
  
        public void destroy()
       {

                 Grid<Actor> gr = getGrid();
                
                 ArrayList<Location> locs = gr.getOccupiedLocations();
                  
                 for (Location loc : locs) {
                    
                     Actor a = gr.get(loc);
                      
                     Location aLoc = a.getLocation();
                      
                     if(aLoc.getCol() == getLocation().getCol() &&
                        
                     aLoc.getRow() > getLocation().getRow()) {
                          
                         a.removeSelfFromGrid();
                        }
                    }
       }
  
       public void move()
       {

           Location next = getLocation().getAdjacentLocation(Location.EAST);
           if(Math.random() < 0.5) {
        
               next = getLocation().getAdjacentLocation(Location.WEST);
                  {
                    if(getGrid().isValid(next)) {
                      moveTo(next);
                             } else {
                                 removeSelfFromGrid();
                                }
                            }
                        }
       }
    }

Wednesday 16 February 2011

Gridworld Part III

Gridworld: Part 3: Classes & Interfaces: Set 3: Page 19




1.

Location loc1 = new Location(4, 3);
Location loc2 = new Location(3, 4);

How would you access the row value for loc1?  

2.
Location loc1 = new Location(4, 3);
Location loc2 = new Location(3, 4);

What is the value of  b  after the following statement is executed?

boolean b = loc1.equals(loc2);


3.
Location loc1 = new Location(4, 3);
Location loc2 = new Location(3, 4);

What is the value of loc3  after the following statement is executed?

Location loc3 = loc2.getAdjacentLocation(Location.SOUTH);

4.
Location loc1 = new Location(4, 3);
Location loc2 = new Location(3, 4);


What is the value of dir  after the following statement is executed?

int dir = loc1.getDirectionToward(new Location(6, 5));

5. How does the getAdjacentLocation()  method know which adjacent location to return?  


Gridworld: Part 3: Classes & Interfaces: Set 4: Page 21



1. How can you obtain a count of the objects in a grid? How can you obtain a count of the empty locations in a bounded grid?

2. How can you check if location (10,10) is in a grid?  

3. Grid contains method declarations, but no code is supplied in the methods.

Why?

Where can you find the implementations of these methods?

4. All methods that return multiple objects return them in an ArrayList.  

Do you think it would be a better design to return the objects in an array?

Explain your answer.  



Gridworld: Part 3: Classes & Interfaces: Set 5: Page 23

 




1
What methods are implemented inCritter?  

2
What are the five basic actions common to all critters when they act?  

3
Should subclasses of Critter override thegetActors()   method?

Explain

4
Describe three ways that a critter could process actors.  

5
What three methods must be invoked to make a critter move?

Explain each of  these methods.  

6
Why is there no Critter constructor?  




Gridworld: Part 3: Classes & Interfaces: Set 6: Page 25-26




1
Which statement(s) in the canMove() method ensures that a bug does not try to move out of its grid?  

2
Which statement(s) in the canMove()method determines that a bug will not walk into a rock?  

3
Which methods of the Grid  interface are invoked by the canMove()  method and why?  

4
Which method of the Location  class is invoked by the canMove() method and why?  

5
Which methods inherited from the Actor class are invoked in the canMove()method?  

6
What happens in the move() method when the location immediately in front of the bug is out of the grid?  

7
Is the variable loc needed in the move()method, or could it be avoided by callinggetLocation() multiple times?  

8
Why do you think the flowers that are dropped by a bug have the same color as the bug?  

9
When a bug removes itself from the grid, will it place a flower into its previous location?  

10
Which statement(s) in the  move() method places the flower into the grid at the bug’s previous location?  

11
If a bug needs to turn 180 degrees, how many times should it call the turn()method?  

12