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

2021/12/31

cant set values and actors not showing image

xixEmilyxix xixEmilyxix

2021/12/31

#
When i hit the start button for my bee simulation it sets my nectar value to -2 an does not show my day value. Im not sure why this part is happening. Also, my flower class are not displaying the image for my flowers - just a green footprint. And im not sure how to get my values of nectar, honey and days over to my end screen world. These are the codes i have atm: beeworld:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
 * Write a description of class BeeWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class BeeWorld extends World
{
    //declare variables
    int beeValue;
    int weatherValue;
    public static Flower flower;
    int dayValue;
    int honeyValue;
    Actor btnAddDay, btnHelp, btnEndSimulation;
    private static final String[] FLOWER_COLOR = { "pink", "purple", "yellow" };
    /**
     * Constructor for objects of class BeeWorld.
     * 
     */
    public BeeWorld(int weatherVal)
    {
        //set background to main screen when button is pressed
        super(864, 540, 1);
        setPaintOrder(Buttons.class);        
        
        setBackground(new GreenfootImage("Background.png"));
                                         
        //declare weatherValue 
        weatherValue = weatherVal;
        
        //set honey value
        honeyValue = 0;
        showText("Honey: " + honeyValue,  810, 110);
        
        //set day value
        dayValue = 0;
        
        //set nectar value
        Forager.nectarValue = 0;
        
        //run new day
        newDay(); 
    }
    
    public void act()
    {
        if (Greenfoot.mouseClicked(btnAddDay))
        {
           newDay();
        }
        if (Greenfoot.mouseClicked(btnHelp))
        {
           help();
        }
        if(Greenfoot.mouseClicked(btnEndSimulation))
        {
           endSimulation();
        }
    }
    
    private void endSimulation()
    {
        Greenfoot.setWorld(new EndScreen()); 
    }
    
    private void help()
    {
        //add help menu
        HelpMenu HelpMenu = new HelpMenu();
        addObject (HelpMenu, getWidth(), getHeight());
        HelpMenu.setLocation(650,200);
        
        //button to be able to remove help menu
        RemoveMenu RemoveMenu = new RemoveMenu();
        addObject (RemoveMenu, getWidth(), getHeight());
        RemoveMenu.setLocation(900,200);
    }
    
    public void runSimulation()
    {
        if(weatherValue >= -40 && weatherValue <= 15)
         {
             //if the weather value is between -40 and 15 then the low temp simulation will run
             lowTemperature();
         } else if(weatherValue >= 16 && weatherValue <= 27)
         {
             //if the weather value is between 16 and 27 then the regular temp simulation will run
             regularTemperature();
         } else if(weatherValue >= 28 && weatherValue <= 40)
         {
             //if the weather value is between 28 and 40 then the high temp simulation will run
             highTemperature();
         }     
    }
    
    private Actor getRandomFlower()
    {
        int colorNum = Greenfoot.getRandomNumber(FLOWER_COLOR.length);
        return new Flower(FLOWER_COLOR[colorNum]);
    }
    
    public void lowTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 500, 250);
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 650, 400);        
    }
    
    public void regularTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);
        addObject(getRandomFlower(), 600, 100);
        addObject(getRandomFlower(), 400, 700);        
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 500, 250);
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        addObject(new Forager(), 520, 175);
        addObject(new Queen(), 500, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 650, 400);       
    }
    
    public void highTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);        
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 500, 250);
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        addObject(new Forager(), 520, 175);
        addObject(new Queen(), 500, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 650, 400);        
    } 
  
        
    public void updateDay()
    {
        //update what day it is and run the next day when the day button is clicked
        dayValue = dayValue +1;
        showText("Day: " + dayValue, 810, 50);
        newDay();
    }
    
    private void newDay()
    {
        //start new day
        //remove all objects
        List objects = getObjects(null);
        removeObjects(objects);
        
        //increase day value
        dayValue++;
        
        //increase honey value
        updateHoney();
        
        //add buttons
        btnAddDay = new Buttons();
        btnAddDay.setImage(new GreenfootImage("addDaybutton.png"));
        btnHelp = new Buttons();
        addObject(btnAddDay, 820, 500);
        btnHelp.setImage(new GreenfootImage("helpButton.png"));
        addObject(btnHelp, 100, 190);
        btnEndSimulation = new Buttons();
        btnEndSimulation.setImage(new GreenfootImage("EndSimulationbutton.png"));
        addObject(btnEndSimulation, 50, 500);
        
        //run simulation again
        runSimulation();       
        
        //add bee every 5 days
        if (dayValue%5 == 0)
        {
           addObject(new Forager(), 550, 250);           
        }
    }     
    
    public void updateHoney()
    {
        //take away from nectar value
        Forager.nectarValue = Forager.nectarValue - 2;
        
        //increase honey value
        honeyValue = honeyValue + 2;
        
        //add the counter for the honey value and nectar value
        showText("Honey: " + honeyValue,  810, 110);
        showText("Nectar: " + Forager.nectarValue,  810, 80);
    }   
}
MainMenu world:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class mainMenu here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MainMenu extends World
{
    //declare variables
    ErrorMessageWeather ErrorMessageWeather;
    WeatherInput weatherInput = new WeatherInput();
    Actor btnHelp, btnStartButton;
    /**
     * Constructor for objects of class mainMenu.
     * 
     */
    public MainMenu()
    {    
        // Create the main menu
        super(864, 540, 1);
        Greenfoot.start();
        setBackground(new GreenfootImage("MainMenu.png"));
        
        //add the help button
        btnHelp = new Buttons();
        btnHelp.setImage(new GreenfootImage("helpButton.png"));
        addObject(btnHelp, 100, 190);
        
        //add start button to main menu
        btnStartButton = new Buttons();
        btnStartButton.setImage(new GreenfootImage("StartButton.png"));
        addObject (btnStartButton, 150, 350); 

        
        //add weather input box to main menu
        addObject (weatherInput, getWidth (), getHeight ()); 
        weatherInput.setLocation(400,250);
    }
    
    public void act()
    {
        if(Greenfoot.mouseClicked(btnStartButton))
        {
           //start simulation when start button is clicked
           startSimulation();
        }
        if (Greenfoot.mouseClicked(btnHelp))
        {
            //show help menu when help button is clicked
            help();    
        }
    }
    
    private void startSimulation()
    {
        Greenfoot.setWorld(new BeeWorld(weatherInput.weatherValue)); 
    }
    
    private void help()
    {
        //add help menu
        HelpMenu HelpMenu = new HelpMenu();
        addObject (HelpMenu, getWidth(), getHeight());
        HelpMenu.setLocation(650,200);
        
        //button to be able to remove help menu
        RemoveMenu RemoveMenu = new RemoveMenu();
        addObject (RemoveMenu, getWidth(), getHeight());
        RemoveMenu.setLocation(900,200);
    }
}
Flower class:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * A pile of food. The pile consists initially of 100 crumbs of food.
 * 
 * @author Michael Kolling
 * @version 1.1
 */
public class Flower extends Actor
{
    //create variable to be able to change colour of flowers
    public String color;
    
    public Flower(String pigment)
    {
        //set image of flowers
        color = pigment;
        GreenfootImage image = new GreenfootImage(color+"Flower.png");  
    }
    
    public void act()
    {        
    }
    
    public boolean touchingForager()
    {
        //check if touching bee then return it
        return isTouching(Forager.class);        
    }
}
End Screen world
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class EndScreen here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class EndScreen extends World
{
    Actor btnMainMenuButton;
    /**
     * Constructor for objects of class EndScreen.
     * 
     */
    public EndScreen()
    {  
        //create end screen
        super(864, 540, 1);
        Greenfoot.start();
        setBackground(new GreenfootImage("EndScreen.png"));
        
        //add main menu button
        btnMainMenuButton = new Buttons();
        btnMainMenuButton.setImage(new GreenfootImage("MainMenubutton.png"));
        addObject(btnMainMenuButton, 50, 500);
        
        //add statistics
        showText("Nectar Value: ", + nectarValue, 420, 270);
        showText("Honey Value: ", + Forager.nectarValue, 420, 290);
        showText("Days: ", + dayValue, 420, 310);
    }
    
    public void act()
    {
        if (Greenfoot.mouseClicked(btnMainMenuButton)) 
        {
           MainMenu();
        }
    }
    
    private void MainMenu()
    {
        Greenfoot.setWorld(new MainMenu()); 
    }
}
The end screen world is giving errors that say it cannot find symbol variable for the nectarValue and the dayValue
danpost danpost

2021/12/31

#
In BeeWorld, updateHoney is called by newDay and decreases the value of nectar by 2. You will need to pass those values, via parameters of the EndScreen constructor to get them to the EndScreen instance from the BeeWorld instance, so they can be displayed there in the end screen.
xixEmilyxix xixEmilyxix

2022/1/1

#
danpost wrote...
In BeeWorld, updateHoney is called by newDay and decreases the value of nectar by 2. You will need to pass those values, via parameters of the EndScreen constructor to get them to the EndScreen instance from the BeeWorld instance, so they can be displayed there in the end screen.
how do i do that?
Spock47 Spock47

2022/1/1

#
xixEmilyxix wrote...
how do i do that?
1. You announce in the constructor of EndScreen which parameters you need: EndScreen, line 16:
public EndScreen(final int nectarValue, final int honeyValue, final int dayValue)
2. When creating an instance of EndScreen, you give the values for these parameters: BeeWorld, line 66:
Greenfoot.setWorld(new EndScreen(Forager.nectarValue, honeyValue, dayValue)); 
3. In EndScreen's constructor, you use the values from the parameters: EndScreen, lines 29-31:
        showText("Nectar Value: ", + nectarValue, 420, 270);
        showText("Honey Value: ", + honeyValue, 420, 290);
        showText("Days: ", + dayValue, 420, 310);
Live long and prosper, Spock47
xixEmilyxix xixEmilyxix

2022/1/2

#
Spock47 wrote...
xixEmilyxix wrote...
how do i do that?
1. You announce in the constructor of EndScreen which parameters you need: EndScreen, line 16:
public EndScreen(final int nectarValue, final int honeyValue, final int dayValue)
2. When creating an instance of EndScreen, you give the values for these parameters: BeeWorld, line 66:
Greenfoot.setWorld(new EndScreen(Forager.nectarValue, honeyValue, dayValue)); 
3. In EndScreen's constructor, you use the values from the parameters: EndScreen, lines 29-31:
        showText("Nectar Value: ", + nectarValue, 420, 270);
        showText("Honey Value: ", + honeyValue, 420, 290);
        showText("Days: ", + dayValue, 420, 310);
Live long and prosper, Spock47
Ive added this and its giving me an error on the showText lines which is: Method showText in class greenfoot.World cannot be applied to given types: required: java.lang.String.int,int found: javalang.String,int int int reason: actual and formal argument lists differ in lengths
public class EndScreen extends World
{
    Actor btnMainMenuButton;
    /**
     * Constructor for objects of class EndScreen.
     * 
     */
    public EndScreen(final int nectarValue, final int honeyValue, final int dayValue)
    {  
        //create end screen
        super(864, 540, 1);
        Greenfoot.start();
        setBackground(new GreenfootImage("EndScreen.png"));
        
        //add main menu button
        btnMainMenuButton = new Buttons();
        btnMainMenuButton.setImage(new GreenfootImage("MainMenubutton.png"));
        addObject(btnMainMenuButton, 50, 500);
        
        //add statistics
        showText("Nectar Value: ", + nectarValue, 420, 270);
        showText("Honey Value: ", + honeyValue, 420, 290);
        showText("Days: ", + dayValue, 420, 310);
    }
    
    public void act()
    {
        if (Greenfoot.mouseClicked(btnMainMenuButton)) 
        {
           MainMenu();
        }
    }
    
    private void MainMenu()
    {
        Greenfoot.setWorld(new MainMenu()); 
    }
}
    private void endSimulation()
    {
        Greenfoot.setWorld(new EndScreen(Forager.nectarValue, honeyValue, dayValue)); 
    }
danpost danpost

2022/1/2

#
xixEmilyxix wrote...
Ive added this and its giving me an error on the showText lines which is: Method showText in class greenfoot.World cannot be applied to given types: required: java.lang.String.int,int found: javalang.String,int int int reason: actual and formal argument lists differ in lengths
Remove the first comma in each of the 3 showText lines given.
xixEmilyxix xixEmilyxix

2022/1/2

#
danpost wrote...
xixEmilyxix wrote...
Ive added this and its giving me an error on the showText lines which is: Method showText in class greenfoot.World cannot be applied to given types: required: java.lang.String.int,int found: javalang.String,int int int reason: actual and formal argument lists differ in lengths
Remove the first comma in each of the 3 showText lines given.
Added this and thats fixed, any ideas about why the flowers arent showing or the day value counter and how to fix the nectarValue starting at -2?
Spock47 Spock47

2022/1/3

#
xixEmilyxix wrote...
any ideas about why the flowers arent showing or the day value counter and how to fix the nectarValue starting at -2?
1. ad "dayValue not shown" The day value is shown, when the updateDay method is called. But the updateDay method seems never to be called from anywhere. 2. ad "nectarValue is -2": Since updateDay is never called, the only time the newDay method is called, is in the constructor of BeeWorld and like danpost pointed out:
danpost wrote...
In BeeWorld, updateHoney is called by newDay and decreases the value of nectar by 2.
Live long and prosper, Spock47
xixEmilyxix xixEmilyxix

2022/1/3

#
Spock47 wrote...
xixEmilyxix wrote...
any ideas about why the flowers arent showing or the day value counter and how to fix the nectarValue starting at -2?
1. ad "dayValue not shown" The day value is shown, when the updateDay method is called. But the updateDay method seems never to be called from anywhere. 2. ad "nectarValue is -2": Since updateDay is never called, the only time the newDay method is called, is in the constructor of BeeWorld and like danpost pointed out:
danpost wrote...
In BeeWorld, updateHoney is called by newDay and decreases the value of nectar by 2.
Live long and prosper, Spock47
So ive figured out the other part and im trying to make it so my method firstTimeValues() is called when my start button is clicked on my main menu so theyre only set once and wont affect when there is an add day. Im not sure how to also call this method though when i change to the bee world? This is where i want to add it: (in the MainMenu world)
    public void act()
    {
        if(Greenfoot.mouseClicked(btnStartButton))
        {
           //start simulation when start button is clicked
           startSimulation();
        }
        if (Greenfoot.mouseClicked(btnHelp))
        {
            //show help menu when help button is clicked
            help();    
        }
    }
    
    private void startSimulation()
    {
        //change to BeeWorld
        Greenfoot.setWorld(new BeeWorld(weatherInput.weatherValue));
        
        //set first time values
    }
and this is the method in the BeeWorld:
    public void firstTimeValue()
    {
        //set honey value
        honeyValue = -2;
        showText("Honey: " + honeyValue,  810, 110);
        
        //set day value
        dayValue = 0;
        
        //set nectar value
        Forager.nectarValue = 2;
        
    }
xixEmilyxix xixEmilyxix

2022/1/4

#
The flowers also still wont show for some reason
danpost danpost

2022/1/4

#
xixEmilyxix wrote...
The flowers also still wont show for some reason
Change line 45 and line 52 in the BeeWorld class codes above to:
updateDay();
Also, change line 223 to:
if (dayValue%5 == 1)
xixEmilyxix xixEmilyxix

2022/1/4

#
danpost wrote...
xixEmilyxix wrote...
The flowers also still wont show for some reason
Change line 45 and line 52 in the BeeWorld class codes above to:
updateDay();
Also, change line 223 to:
if (dayValue%5 == 1)
Ive done this and now what happens when i press the start button is the honey value shows 2, the day value shows 1 and nothing else shows. None of the flowers or bees this is my code:
public class BeeWorld extends World
{
    //declare variables
    int beeValue;
    int weatherValue;
    public static Flower flower;
    int dayValue;
    int honeyValue;
    Actor btnAddDay, btnHelp, btnEndSimulation;
    private static final String[] FLOWER_COLOR = { "pink", "purple", "yellow" };
    /**
     * Constructor for objects of class BeeWorld.
     * 
     */
    public BeeWorld(int weatherVal)
    {
        //set background to main screen when button is pressed
        super(864, 540, 1);
        setPaintOrder(Buttons.class);        
        
        setBackground(new GreenfootImage("Background.png"));
                                         
        //declare weatherValue 
        weatherValue = weatherVal;
        
        //set honey value
        honeyValue = 2;
        showText("Honey: " + honeyValue,  810, 110);
        
        //set day value
        dayValue = 0;
        
        //set nectar value
        Forager.nectarValue = 2;
        
        //run new day
        updateDay();        
    }
    
    public void firstTimeValue()
    {
        
    }
    
    public void act()
    {
        if (Greenfoot.mouseClicked(btnAddDay))
        {
           updateDay();
        }
        if (Greenfoot.mouseClicked(btnHelp))
        {
           help();
        }
        if(Greenfoot.mouseClicked(btnEndSimulation))
        {
           endSimulation();
        }
    }
    
    private void endSimulation()
    {
        Greenfoot.setWorld(new EndScreen(Forager.nectarValue, honeyValue, dayValue)); 
    }
    
    private void help()
    {
        //add help menu
        HelpMenu HelpMenu = new HelpMenu();
        addObject (HelpMenu, getWidth(), getHeight());
        HelpMenu.setLocation(650,200);
        
        //button to be able to remove help menu
        RemoveMenu RemoveMenu = new RemoveMenu();
        addObject (RemoveMenu, getWidth(), getHeight());
        RemoveMenu.setLocation(820, 310);
    }
    
    public void runSimulation()
    {
        if(weatherValue >= -40 && weatherValue <= 15)
         {
             //if the weather value is between -40 and 15 then the low temp simulation will run
             lowTemperature();
         } else if(weatherValue >= 16 && weatherValue <= 27)
         {
             //if the weather value is between 16 and 27 then the regular temp simulation will run
             regularTemperature();
         } else if(weatherValue >= 28 && weatherValue <= 40)
         {
             //if the weather value is between 28 and 40 then the high temp simulation will run
             highTemperature();
         }     
    }
    
    private Actor getRandomFlower()
    {
        int colorNum = Greenfoot.getRandomNumber(FLOWER_COLOR.length);
        return new Flower(FLOWER_COLOR[colorNum]);
    }
    
    public void lowTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 400, 210);
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 450, 250);        
    }
    
    public void regularTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);
        addObject(getRandomFlower(), 600, 100);
        addObject(getRandomFlower(), 400, 700);        
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 400, 210);;
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        addObject(new Forager(), 520, 175);
        addObject(new Queen(), 500, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 450, 250);       
    }
    
    public void highTemperature()
    {
        //add random coloured flowers to the bee world
        addObject(getRandomFlower(), 500, 500);
        addObject(getRandomFlower(), 100, 300);
        addObject(getRandomFlower(), 200, 400);
        addObject(getRandomFlower(), 100, 100);
        addObject(getRandomFlower(), 700, 400);
        addObject(getRandomFlower(), 800, 200);        
        
        //add bees to the bee world
        Worker Worker = new Worker ();
        Queen Queen = new Queen ();
        Forager Forager = new Forager ();
        addObject(new Queen(), 400, 210);
        addObject(new Forager(), 400, 150);
        addObject(new Forager(), 450, 200);
        addObject(new Forager(), 500, 220);
        addObject(new Forager(), 550, 250);
        addObject(new Forager(), 520, 175);
        addObject(new Queen(), 500, 250);
        
        //add the hive to the bee world
        Hive Hive = new Hive ();
        addObject(new Hive(), 450, 250);        
    } 
  
        
    public void updateDay()
    {
        //update what day it is and run the next day when the day button is clicked
        dayValue = dayValue +1;
        showText("Day: " + dayValue, 810, 50);
    }
    
    private void newDay()
    {
        //start new day
        updateDay();
        
        //remove all objects
        List objects = getObjects(null);
        removeObjects(objects);
        
        //increase day value
        dayValue++;
        
        //increase honey value
        updateHoney();
        
        //add buttons
        btnAddDay = new Buttons();
        btnAddDay.setImage(new GreenfootImage("addDaybutton.png"));
        btnHelp = new Buttons();
        addObject(btnAddDay, 820, 500);
        btnHelp.setImage(new GreenfootImage("helpButton.png"));
        addObject(btnHelp, 70, 30);
        btnEndSimulation = new Buttons();
        btnEndSimulation.setImage(new GreenfootImage("EndSimulationbutton.png"));
        addObject(btnEndSimulation, 50, 500);
        
        //run simulation again
        runSimulation();       
        
        //add bee every 5 days
        if (dayValue%5 == 1)
        {
           addObject(new Forager(), 550, 250);           
        }
    }     
    
    public void updateHoney()
    {
        //take away from nectar value
        Forager.nectarValue = Forager.nectarValue - 2;
        
        //increase honey value
        honeyValue = honeyValue + 2;
        
        //add the counter for the honey value and nectar value
        showText("Honey: " + honeyValue,  810, 110);
        showText("Nectar: " + Forager.nectarValue,  810, 80);
    }   
}
danpost danpost

2022/1/4

#
xixEmilyxix wrote...
Ive done this and now what happens when i press the start button is the honey value shows 2, the day value shows 1 and nothing else shows. None of the flowers or bees this is my code: << Code Omitted >>
Apparently, you have moved more stuff around or modified your code from what was previously given above. Remove lines 193 and 194. Then, at the end of your updateDay method add the following line:
newDay();
xixEmilyxix xixEmilyxix

2022/1/5

#
danpost wrote...
xixEmilyxix wrote...
Ive done this and now what happens when i press the start button is the honey value shows 2, the day value shows 1 and nothing else shows. None of the flowers or bees this is my code: << Code Omitted >>
Apparently, you have moved more stuff around or modified your code from what was previously given above. Remove lines 193 and 194. Then, at the end of your updateDay method add the following line:
newDay();
Ahh sorry yeah, that fixed it. But not the flowers turning up as a green footprint - how would i go about fixing that?
danpost danpost

2022/1/5

#
xixEmilyxix wrote...
the flowers turning up as a green footprint - how would i go about fixing that?
In Flower class, modify the constructor to this (adding line 6):
public Flower(String pigment)
{
    //set image of flowers
    color = pigment;
    GreenfootImage image = new GreenfootImage(color+"Flower.png");
    setImage(image);
}
You need to login to post a reply.