What does this mean and how can I fix it.
I am trying to get an variable which changes if a button if clicked. The actor (modificationscreen) is in one world (terrainone) whereas the variable has to be cast in another world.
//this is the actor in modification screen
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class skisbutton here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class skisbutton extends Actor
{
public int selectionskis=0;
/**
* Act - do whatever the tracksbutton wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.mouseClicked(this))
{
GreenfootImage image = getImage();
image.scale(image.getWidth()+30,image.getHeight()+30);
setImage(image);
terrainone terrainoneWorld = (terrainone) getWorld();
skisbutton skisbutton = terrainoneWorld.gettheselectionskisValue();
selectionskis=1;
getshared();
}
}
public int getshared(){
return selectionskis;
}
}//this is the terrainone world where I want the actor skisbutton to cast to
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class terrainone here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class terrainone extends World
{
private Counter theCounter;
private Counter2 theCounter2;
private Counter3 theCounter3;
public tracksbutton theselectiontracksValue;
public skisbutton theselectionskisValue;
public wheelsbutton theselectionwheelsValue;
public largebaybutton thebaysizeselectionlargeValue;
public mediumbaybutton thebaysizeselectionmediumValue;
public smallbaybutton thebaysizeselectionsmallValue;
/**
* Constructor for objects of class terrainone.
*
*/
public terrainone()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(10, 11, 60);
setBackground("cell.jpg");
setPaintOrder(robot.class, person.class, grasspicture.class, grass.class);
setPaintOrder(robot.class, person.class, rockpicture.class, rock.class);
locationbuilder();
}
private void locationbuilder()
{
addObject(new bottombanner(), 0 , 10);
addObject(new bottombanner(), 1 , 10);
addObject(new bottombanner(), 2 , 10);
addObject(new bottombanner(), 3, 10);
addObject(new bottombanner(), 4 , 10);
addObject(new bottombanner(), 5 , 10);
addObject(new bottombanner(), 6 , 10);
addObject(new bottombanner(), 7, 10);
addObject(new bottombanner(), 8 , 10);
addObject(new bottombanner(), 9 , 10);
addObject(new person(), 2 , 0);
addObject(new person(), 7, 2);
addObject(new person(), 9 , 6);
addObject(new person(), 4 , 6);
theCounter = new Counter();
theCounter2 = new Counter2();
theCounter3 = new Counter3();
addObject(new carryinginfo(), 6 , 10);
addObject(new powerinfo(), 1 , 10);
addObject(theCounter, 3, 10);
addObject(theCounter2, 8, 10);
addObject(theCounter3, 9, 10);
//addObject(new robot(),0,0);
addObject(new basecamp(), 6, 3);
theselectiontracksValue = new tracksbutton();
theselectionskisValue = new skisbutton();
theselectionwheelsValue = new wheelsbutton();
thebaysizeselectionlargeValue = new largebaybutton();
thebaysizeselectionmediumValue = new mediumbaybutton();
thebaysizeselectionsmallValue = new smallbaybutton();
int selectiontracksValue = ((tracksbutton) getObjects(tracksbutton.class).get(0)).getshared();
int selectionskisValue = ((skisbutton) getObjects(skisbutton.class).get(0)).getshared();
int selectionwheelsValue = ((wheelsbutton) getObjects(wheelsbutton.class).get(0)).getshared();
int baysizeselectionlargeValue = ((largebaybutton) getObjects(largebaybutton.class).get(0)).getshared();
int baysizeselectionmediumValue = ((mediumbaybutton) getObjects(mediumbaybutton.class).get(0)).getshared();
int baysizeselectionsmallValue = ((smallbaybutton) getObjects(smallbaybutton.class).get(0)).getshared();
if (selectiontracksValue>0&&baysizeselectionlargeValue>0){
addObject(new robottrackslarge(), 6, 3);
}
else if (selectiontracksValue>0&&baysizeselectionmediumValue>0){
addObject(new robottracksmedium(), 6, 3);
}
else if (selectiontracksValue>0&&baysizeselectionsmallValue>0){
addObject(new robottrackssmall(), 6, 3);
}
else if (selectionskisValue>0&&baysizeselectionlargeValue>0){
addObject(new robotskislarge(), 6, 3);
}
else if (selectionskisValue>0&&baysizeselectionmediumValue>0){
addObject(new robotskismedium(), 6, 3);
}
else if (selectionskisValue>0&&baysizeselectionsmallValue>0){
addObject(new robotskissmall(), 6, 3);
}
else if (selectionwheelsValue>0&&baysizeselectionlargeValue>0){
addObject(new robotwheelslarge(), 6, 3);
}
else if (selectionwheelsValue>0&&baysizeselectionmediumValue>0){
addObject(new robotwheelsmedium(), 6, 3);
}
else if (selectionwheelsValue>0&&baysizeselectionsmallValue>0){
addObject(new robotwheelssmall(), 6, 3);
}
}
public Counter getCounter()
{
return theCounter;
}
public Counter2 getCounter2()
{
return theCounter2;
}
public tracksbutton gettheselectiontracksValue()
{
return theselectiontracksValue;
}
public skisbutton gettheselectionskisValue()
{
return theselectionskisValue;
}
public wheelsbutton gettheselectionwheelsValue()
{
return theselectionwheelsValue;
}
public largebaybutton getthebaysizeselectionlargeValue()
{
return thebaysizeselectionlargeValue;
}
public mediumbaybutton getthebaysizeselectionmediumValue()
{
return thebaysizeselectionmediumValue;
}
public smallbaybutton getthebaysizeselectionsmallValue()
{
return thebaysizeselectionsmallValue;
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Modificationscreen here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Modificationscreen extends World
{
/**
* Constructor for objects of class Modificationscreen.
*
*/
public Modificationscreen()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(10, 10, 60);
addObject(new skisbutton(), 3 , 2);
addObject(new tracksbutton(), 5 , 2);
addObject(new wheelsbutton(), 7 , 2);
addObject(new largebaybutton(), 7 , 3);
addObject(new mediumbaybutton(), 5 , 3);
addObject(new smallbaybutton(), 3 , 3);
addObject(new backbutton(), 8 , 7);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
}
}