danpost wrote...
Remove lines 46 and 47 from here and add the following after line 6 above:
beeWorld.runSimulation();
beeWorld.runSimulation();
public void runSimulation() { int weatherValue = WeatherInput.weatherValue; 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(); } }
WeatherInput weatherInput;
weatherInput = new WeatherInput();
WeatherInput weatherInput;
int weatherValue;
public BeeWorld()
public BeeWorld(int weatherVal)
runSimulation();
weatherValue = weatherVal;
BeeWorld beeWorld = new BeeWorld();
BeeWorld beeWorld = new BeeWorld(weatherInput.weatherValue);
public class BeeWorld extends World { //declare variables int beeValue; Flower PinkFlower; Flower PurpleFlower; Flower YellowFlower; StartButton StartButton; int WeatherInput; Hive Hive; Bee Forager; Bee Worker; Bee Queen; /** * Constructor for objects of class BeeWorld. * */ public BeeWorld(int weatherVal) { //set background to main screen when button is pressed super(864, 540, 1); setBackground(new GreenfootImage("Background.png")); //add the add day button AddDay AddDay = new AddDay (); addObject (AddDay, getWidth (), getHeight()); AddDay.setLocation(820,500); //add the bee counter showText(("Bees: " + beeValue), 810, 20); //add the day counter showText("Day: 0", 820, 50); //add the honey counter showText("Honey: 0", 810, 110); //add the help button HelpButton HelpButton = new HelpButton (); addObject (HelpButton, getWidth (), getHeight ()); HelpButton.setLocation(100,190); weatherValue = weatherVal; runSimulation(); } 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(); } }
public MainMenu() { // Create the main menu super(864, 540, 1); Greenfoot.start(); setBackground(new GreenfootImage("MainMenu.png")); //add the help button HelpButton HelpButton = new HelpButton (); addObject (HelpButton, getWidth (), getHeight ()); HelpButton.setLocation(100,190); //add start button to main menu StartButton StartButton = new StartButton (); addObject (StartButton, getWidth (), getHeight ()); StartButton.setLocation(150,350); //add weather input box to main menu addObject (WeatherInput, getWidth (), getHeight ()); WeatherInput.setLocation(400,250); }
int weatherValue;
public void act() { if (Greenfoot.mouseClicked(this)) { setWorld(new BeeWorld(((MainMenu)getWorld()).weatherInput.weatherValue)); } }
addObject (weatherInput, getWidth (), getHeight ()); WeatherInput.setLocation(400,250);
setWorld(new BeeWorld(((MainMenu)getWorld()).weatherInput.weatherValue));
addObject (weatherInput, getWidth (), getHeight ()); WeatherInput.setLocation(400,250);
weatherInput.setLocation(400,250);
setWorld(new BeeWorld(((MainMenu)getWorld()).weatherInput.weatherValue));
Greenfoot.setWorld(new BeeWorld(((MainMenu)getWorld()).weatherInput.weatherValue));
WeatherInput weatherInput = new WeatherInput();