Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: GridWorld Code - Need Help

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Exclamation GridWorld Code - Need Help

    I'm writing a bug called HomerBug.
    HomerBug is a subclass of Bug.
    HomerBug chooses a DumbRainbowBug in the Grid.
    If there are no DumbRainbowBugs, it does nothing.
    Otherwise it takes one step closer to the DumbRainbowBug every step, plowing over everything in its path, until it kills the DumbRainbowBug.

    I have already written DumbRainbowBug, essentially I need help establishing the location of 1 or all of the DumbRainbowBugs in the grid. I want to call the getLocation() method from DumbRainbowBug and use that location in HomerBug, but I can't seem to do it. Any and all help is appreciated, thanks.

    Here is my fail code thus far:
    import info.gridworld.actor.Bug;
    import info.gridworld.grid.Grid;
    import info.gridworld.grid.Location;
    import info.gridworld.actor.Actor;
    import info.gridworld.grid.*;
     
     
     
    import java.util.*;
     
    import java.awt.Color;
     
    public class HomerBug extends Bug
    {
    	public HomerBug()
    	{
    		setColor(Color.PINK);
    	}
     
    	public void act()
    	{		
            	//Location loc = new Location((DumbRainBowBug)DumbRainBowBug.getLocation());
    		//Location loc = new Location(DumbRainBowBug.getLocation());
    		//Location z = getLocation();
    		//System.out.println(z.getDirectionToward(loc));
     
    	}
    }


  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: GridWorld Code - Need Help

    Isn't this one of the AP Comp Sci questions? If so, most people here won't be able to help you out until you give links to the relevant documentation (jdoc).