AP Notes, Outlines, Study Guides, Vocabulary, Practice Exams and more!

Need Helpp!!

3 posts / 0 new
Last post
tiro-to-java's picture
Offline
Joined: Feb 2007
Need Helpp!!

Ok
the task here to generate a random number either 0 or 1
if its 0 then the fish will be red
if its 1 then the fish will be blue

here is the code i've written..
help me with it..

//Welcoming users
System.out.println("WELCOME TO THE AQUARIUM STIMULATIONS");
// CONSTRUCT OBJECTS NEEDED FOR THE AQUARIUM SIMULATION.

// Construct the aquarium. Specify its dimensions when creating it.
Aquarium aqua; // create reference to an Aquarium ...
//aqua = new Aquarium(600, 480);// ... object that has now been created
aqua = new Aquarium(100, 480);// ... object that has now been created

//generating a random value
Random randNumGen = RandNumGenerator.getInstance();
int randomNum = randNumGen.nextInt();

Color fishColor = new Color();

//consturcting a fish

AquaFish AquariumFish = new AquaFish(aqua);

//creating three new fish
AquaFish aquaFish1 = new AquaFish(aqua);
// -----------------------------------------------------------------
AquaFish aquaFish2 = new AquaFish(aqua);
// -----------------------------------------------------------------
AquaFish aquaFish3 = new AquaFish(aqua);
//---------------------------------------------------------------

if (randomNum == 1){
(fishColor(Color.blue));

}

if (randomNum =0){
fishColor.setColor(Color.red);
}

I need help with how to set the color...
thanks
plz reply asap.

Hunterbender's picture
Offline
Joined: Nov 2007

Heh, I don't think you need help anymore..cuz..it's sort of an old post. i wish I register earlier

NPEng's picture
Offline
Joined: Nov 2007

haha i had to write a code like that except it was a coin and its sides and not a fish and its colors

Need Help?

We hope your visit has been a productive one. If you're having any problems, or would like to give some feedback, we'd love to hear from you.

For general help, questions, and suggestions, try our dedicated support forums.

If you need to contact the Course-Notes.Org web experience team, please use our contact form.

Need Notes?

While we strive to provide the most comprehensive notes for as many high school textbooks as possible, there are certainly going to be some that we miss. Drop us a note and let us know which textbooks you need. Be sure to include which edition of the textbook you are using! If we see enough demand, we'll do whatever we can to get those notes up on the site for you!