CourseNotes
Published on CourseNotes (https://course-notes.org)

Home > Need Helpp!!

3 posts / 0 new
Last post [1]
February 21, 2007 - 22:55
#1 [2]
tiro-to-java [3]
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.

Top

Source URL:https://course-notes.org/forum/math/ap_computer_science/need_helpp

Links
[1] https://course-notes.org/forum/math/ap_computer_science/need_helpp#comment-1066021 [2] https://course-notes.org/forum/math/ap_computer_science/need_helpp [3] https://course-notes.org/user/47483