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

2011/6/11

On fixing 'Infect'

2
3
4
5
6
danpost danpost

2011/6/27

#
kiarocks -- I am back!
kiarocks kiarocks

2011/6/27

#
tested it yet?
danpost danpost

2011/6/27

#
My bad -- error was do to 'void' in constructor -- remove that word!
kiarocks kiarocks

2011/6/27

#
age rate not found
kiarocks kiarocks

2011/6/27

#
age++;  
        int actualAge = (age - (age % EpidemicWorld.ageRate) ) / EpidemicWorld.ageRate; // Computes actual age  
        if (age % EpidemicWorld.ageRate == 0) // asking if is an actual birthday  
        {  
            switch (actualAge)  
            {  
                case 13:  
                infectChance = 10;  
                deathChance = 1;  
                procreateChance = 2;  
                break;  
                case 18:  
                infectChance = 15;  
                deathChance = 5;  
                procreateChance = 10;  
                break;  
                case 21:  
                deathChance = 3;  
                procreateChance = 15 - 5 * infectionLevel;  
                break;  
                case 26:  
                procreateChance = 20 - 5 * infectionLevel;  
                case 35:  
                procreateChance = 5 - infectionLevel;  
                case 50:  
                procreateChance = 0;  
                infectChance = 20;  
                deathChance = 5;  
                case 60:  
                infectChance = 25;  
                deathChance = 8;  
                case 75:  
                infectChance = 30;  
                deathChance = 12;  
            }  
        }  
davmac davmac

2011/6/27

#
kiarocks, if an error says that something isn't found you need to assess why that is the case. Your code has:
int actualAge = (age - (age % EpidemicWorld.ageRate) ) / EpidemicWorld.ageRate;
So, you are accessing "ageRate" as a class variable in EpidemicWorld (I'm assuming EpidemicWorld is the name of your world class). Does such a variable actually exist? Have you declared it in EpidemicWorld? Is it definitely a variable and not a method? (If it's a method you need to put "()" after the name to signify a method call). Is it definitely a class variable (declared as "static")? - if not perhaps you should be accessing it in a different way. My point is, just looking at the code where you get the error is not enough to tell what the problem is nor how to fix it. Can you also show the declaration of "ageRate" in the EpidemicWorld class?
danpost danpost

2011/6/27

#
kiarocks, you need to change all references to 'EpidemicWorld' and change them to 'InfectWorld'
kiarocks kiarocks

2011/6/27

#
no dan post, it is epidemic world on mine. and davmac, i have not declared it, danpost, whats in you world statement??
danpost danpost

2011/6/27

#
I have played around with it, and right now I have this declaration statement in EpidemicWorld
public static final int ageRate = 5;
My EpidemicWorld begin like this:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;  // (List)

public class EpidemicWorld extends World
{
    public static final int ageRate = 5;

    public EpidemicWorld()
    {    
        super(25, 25, 25); 
        populateWorld();
    }
Followed by 'public void populateWorld(){...}'
danpost danpost

2011/6/27

#
'ageRate' is the number of cycles that represent a year; I am thinking about changing it to '8'. 1) So they do not die off so quickly 2) Term-length (pregnancy) would be an even 6 cycles (3/4th of a year) Or, maybe better would be '12' (each cycle would represent a month; and 12 months is a full year); therefore '9' would be Term-length (pregnancy) in months (which is normal). Anyways, make yours whatever you feel comfortable with!
kiarocks kiarocks

2011/6/28

#
ok, ill see if it works
kiarocks kiarocks

2011/6/28

#
would the procreate method be void or boolean?
kiarocks kiarocks

2011/6/28

#
and would it be public or private?
danpost danpost

2011/6/28

#
This is what i used in the Person class:
    
    private void procreate(int procChance)
    {
        List<Person>persons = getObjectsInRange(2, Person.class);
        int maleCt = 0;
        for (Person person: persons) { if (person.sex == 1 && person.infectionStage < 2) { maleCt++; } }
        if (Greenfoot.getRandomNumber(100) < procChance * maleCt)
        {
            isPregnant = true;
            howLongTillDue = EpidemicWorld.ageRate * 3 / 4;
        }
    }
I used sex = 0 for female, and sex = 1 for male. Also, i checked to see if sex of Person 'act'ing on is 0 (female) before calling this method.
kiarocks kiarocks

2011/6/28

#
ok, might work now-no errors at least!
There are more replies on the next page.
2
3
4
5
6