This site requires JavaScript, please enable it in your browser!
Greenfoot back
Jemy
Jemy wrote ...

2021/5/10

How to generate the entire timing of the simulation

1
2
danpost danpost

2021/5/13

#
Jemy wrote...
i think this method will replace the serverpopulation
No. It will not.
Jemy Jemy

2021/5/13

#
danpost wrote...
Jemy wrote...
i think this method will replace the serverpopulation
No. It will not.
i think it will be called in the serverpopulation method and setActive will decide the server that will be active or not
Jemy Jemy

2021/5/13

#
Jemy wrote...
danpost wrote...
Jemy wrote...
i think this method will replace the serverpopulation
No. It will not.
i think it will be called in the serverpopulation method and setActive will decide the server that will be active or not
Thinking SetActive method will look like this:
public void setActive(boolean value){
        int x= Greenfoot.getRandomNumber(getWidth());
        int y= Greenfoot.getRandomNumber(getHeight());
        addObject(new Server(value), x, y);
    }
danpost danpost

2021/5/14

#
Jemy wrote...
i think it will be called in the serverpopulation method and setActive will decide the server that will be active or not
No. The method I gave decides which ones will be active. The setActive method that goes in the Server class will just set a Server object active or not active depending on the given boolean value.
Jemy Jemy

2021/5/14

#
danpost wrote...
Jemy wrote...
i think it will be called in the serverpopulation method and setActive will decide the server that will be active or not
No. The method I gave decides which ones will be active. The setActive method that goes in the Server class will just set a Server object active or not active depending on the given boolean value.
I hope the method i wrote above is correct for setActive. but the setActiveServers needs to be called, i think it will be called in world constructor
danpost danpost

2021/5/14

#
Jemy wrote...
I hope the method i wrote above is correct for setActive.
How can it be, when it creates Server objects and it is coded to be in a World subclass?
the setActiveServers needs to be called, i think it will be called in world constructor
Yes -- AFTER calling serverPopulation.
You need to login to post a reply.
1
2