Jump to content

newageslackr

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by newageslackr

  1. yes, adding that line should fix the problem with the null pointer.
  2. I have a basic understanding of the polar coordinate system. I have some questions that would help me with my hw though. (1) how do I take an equation like 3cos(5 theta) and figure out how big an interval is for one loop. I know that there are 5 loops, i just don't know how to get the interval. (2)i know that when integrating to get area im going to take .5( integral from angle a to angle b of r^2 dtheta) i also know that if im finding the area between two curves i take the difference of r1^2 and r2^2 depending on whic yields a greater value, would i break the intervals up for when one function was greater then the other. any help is appreciated
  3. hey im newageslackr, I'm a 16 year old with massive interests in Computer Science, I excel at Math, at least so far. I'm looking forward to possibly learning some new things.
  4. The idea is to use inheritance, so you would just override the methods. it would be the same method header as the super class. For the knight fish, all you would have to do is have the constructors and override the emptyNeighbors() function. this function gets the locations that you can move to. so you could create an ArrayList(remember to import java.util.*) and add all the possible moves to the ArrayList. An example of this would be: ArrayList nbrs = new ArrayList(); nbrs.add(new Location(location().row() - 2, location().col() - 1); ... you could then take the code at the end of the emptyNeighbors() method from the Fish class and append it to yours. I believe this is the code that is there: ArrayList emptyNbrs = new ArrayList(); for ( int index = 0; index < nbrs.size(); index++ ) { Location loc = (Location) nbrs.get(index); if ( environment().isEmpty(loc) ) emptyNbrs.add(loc); } return emptyNbrs; and there you have it, your first unique fish. One thing to remember, because of inheritance you only have to change a method or two, not all of them. Hope this helps
  5. To create unique fish, you would have to extend the fish class and implement its constructors. Then you can create new nextLocation(), move(), and act() methods that define your new fish. For the knight in particular you could just extend emptyNeighbors() and return an arraylist containing all possible moves that fit the knights movement. I'm pretty sure thats all you need, unless I'm mistaken.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.