augment Posted March 25, 2006 Posted March 25, 2006 I'll be taking this may and we just started our marine biology case study for it. Anyone else take this and was it hard?
Pleiades Posted March 26, 2006 Posted March 26, 2006 I took it and got a 4. I didn’t find it that hard, but its dependant on ability. I learned VB the year before, if you have some programming experience it won’t be too hard. I had quite a lot of fun messing around with the fish, I tried to give them some simple AI to get them to swim in a school, it didn’t work very well though; they just sort of clumped together. Lol, good times.
Cloud Posted March 27, 2006 Posted March 27, 2006 Isn't this course in java? VB would have been pretty much useless yet you still managed a 4. I think this further supports why it isn't that hard (in respect to the initial Question)
Pleiades Posted March 27, 2006 Posted March 27, 2006 Yes it’s in Java, but once you know one language, it’s much easier to learn another.
TheGeek Posted March 28, 2006 Posted March 28, 2006 can somone help me make a unique fish? there are two types of fish right now the slowfish and the darter fish. How do i make something new that'll move like a knight on a chess board?
newageslackr Posted March 28, 2006 Posted March 28, 2006 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.
TheGeek Posted March 30, 2006 Posted March 30, 2006 i don't know how to check two front and one to the right for the knight. Can someone give an example line of code to do so? So far i've extended the fish class and i've made constructors. I don't know how to do the move and next location. I don't have school this week so i don't know how to get help. thanks
newageslackr Posted March 30, 2006 Posted March 30, 2006 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now