Results 1 to 7 of 7
  1. #1
    bob101 is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default Java Problem. Need Help!

    Hello guys.

    I need to write a program that simulates life in a fish tank. Different types of fish have different characteristics (e.g. size, appetite, etc.) and behavior (e.g. aggressive, lazy etc.). Fish move according to attitude, hunger, proximity of other fish or food etc. At least 3 different types of fish must be present in the
    tank at all times, and at least two different sources of fish food. I will also need a way to feed them.

    any ideas on how i can get this started. i havent got a clue.

    i have got some tips:

    - the program reads and prints the details and status of the fish in the simulation. (screen output, keyboard input and basic classes)
    - the fish can move inside the tank. (methods and variables)

    Thanks for your help.

    p.s. i am using bluej

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    i havent got a clue.
    This doesn't bode well as our track record to help folks truly in this situation is very poor. If you truly haven't got a clue, you are far better talking to your teacher as soon as possible and get some remedial tutorials. If you have got some ideas, you'd best start posting them here.

    If this were my program though the first thing I'd do would be to figure out what objects are needed -- objects that here will correspond to physical objects. I'd get a note card for each class and start writing down properties (variables) and behaviors (methods) that the classes have. I'd say, get out some paper or cards and a pen and have a go at this. When you're done with this feel free to let us know what classes you've decided on creating and what properties/behaviors you think they should have.

    Good luck.

  3. #3
    bob101 is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    o, sorry. i thought this forum was to help people like me about java.

    however, for those who have got any idea on how i could get his started, i would really appreciate it.

    three classes could be fish(different types of fish), characteristics of the fish, behavior? i dont no. if any ones got any ideas please let me know otherwise, well dont worry i guess

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by bob101 View Post
    o, sorry. i thought this forum was to help people like me about java.
    this may not help you get more help.

    however, for those who have got any idea on how i could get his started, i would really appreciate it.
    I have given you some suggestions. Have you considered them?

    three classes could be fish(different types of fish), characteristics of the fish, behavior? i dont no.
    The assignment actually lists what the fish need. If it were my assignment I'd give my fish variables to correspond to each characteristic such as ints to describe the fish's size, aggressiveness, etc...

    and methods for activities such as move and eat. I'd use the characteristics above to decide how much it will eat when it reaches food, and how far it will move.
    Last edited by Fubarable; 03-17-2009 at 02:02 PM.

  5. #5
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    well... first you have to figure out a conception of you future program. Not a code first but
    1) conception
    2) structure
    3) ligic
    4) code
    You have only an unclear idea and that's all you nave for now :(
    As soon as you get through those 3 pointed steps and get close to code step. Then you write code and a problem appears and you asks us how to cope the problem... You know I mean? And here we may start thinking over your code problem :)

  6. #6
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Forum is not an ideas center but a place where people share their programming skills. Mayby ideas too... But the ideas must be figured out in a code view.

  7. #7
    hashemg is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default

    Hey,

    I've got the same assignment and I'm getting the feeling we attend the same university. I haven't started my assignment yet but I've got a general feel for the thing.

    Here is a good way of thinking about it:

    You want three different types of fish.

    So: You want a superclass for 'fish'. Every fish will have some properties that will apply to every type of fish, so set these in the superclass. For example: You might want a variable for aggressiveness. Every type of fish will have that same variable, but it won't have the same value.

    Add variables in the superclass for every property that fish should have. (Another example, movement speed)

    Then write methods that fish should have, a good example is a method for 'feed' or 'move'. Every fish is going to need to both move and feed so these are good to have in the superclass.

    Then you are going to want to write classes for every individual type of fish, you remember inheritance from the lectures? This is where it comes in.

    A type of fish is a goldfish, for example.

    So goldfish extends fish, then your goldfish class will inherit all the properties and methods of the fish superclass, so your goldfish is a fish. But a goldfish won't be as aggressive as say a piranah, so you need to set the agressiveness of a goldfish here to a low number. Or maybe in your simulation it is faster than a piranah, so set the speed variable accordingly.

    Don't forget that the variables don't do anything without the code that creates the simulation to go with it. That is going to be much more time consuming to do. You're going to need a basic GUI, with methods that use co-ordinates to find the locations of all your types of fish and food sources, and so on.

    Those are just very basic examples to get you started, because I know the deadline is coming up if you are indeed at my university.

Similar Threads

  1. Help, java problem
    By Suriman in forum New To Java
    Replies: 4
    Last Post: 03-09-2009, 04:26 PM
  2. problem with java nio
    By andrei stoiculescu in forum Networking
    Replies: 3
    Last Post: 02-02-2009, 03:35 PM
  3. Java problem
    By grend in forum New To Java
    Replies: 5
    Last Post: 08-18-2008, 11:44 PM
  4. Problem in java
    By saytri in forum New To Java
    Replies: 4
    Last Post: 01-16-2008, 10:09 PM
  5. java SE 6 problem
    By techlance in forum Java Applets
    Replies: 1
    Last Post: 06-28-2007, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •