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

2011/6/11

On fixing 'Infect'

3
4
5
6
kiarocks kiarocks

2011/6/28

#
can you create a loop for it to do if it is dead?? I have
if(myImage=("ppl5.png(wrong thing-what would i put for the greenfoot image?")) { do; while(<illegal start of expression>) }
danpost danpost

2011/6/28

#
Instead of checking what image is set for the Person, since all dead are infectionStage = 5, check for that! Next, use standard formatting (open bracket after 'if' on a single line by itself, and the statements to execute when the 'if' condition is 'true' indented, and finally the close bracket on a single line. That way if you get another error, the only thing highlighted will be the expression with the error.
danpost danpost

2011/6/28

#
Curious :] What are the dead doing, and what condition are you checking to stop them from doing it?
kiarocks kiarocks

2011/6/28

#
ill show you
danpost danpost

2011/6/28

#
No, I do not see. But I did see something: In Person.class, change your statement: 'infect(infectChance);' to this: 'infect(infectChance * getInfectChance);' That way a Person only gets infected when in contact with a Person who already is infected. But you would need to add: In EpidemicWorld.class, 'addObject(new Person(25, 1), randomX, randomY);' and 'addObject(new Person(30,2), randomX, randomY);' as initial infecteds (otherwise no-one would get infected).
kiarocks kiarocks

2011/6/28

#
its hard to notice but they resize themselves slightly when they are dead.
kiarocks kiarocks

2011/6/28

#
that fails, try it out yourself
infect(infectChance * getInfectChance);
danpost danpost

2011/6/28

#
Sorry, let me look at it again; I will let you know shortly what I found.
danpost danpost

2011/6/28

#
OK, try: 'infect(infectChance * getInfectChance());' (missed the parenthesis after 'getInfectChance')
You need to login to post a reply.
3
4
5
6