Hi again guys. Just putting that in, firstly, what does typecast mean? And when i compile what Danpost and then davmac put it tells me that worldWorld (sorry about name will change that) is not a variable. Do I have to make it first?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class robottrackslarge here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class robot extends Actor
{
public void addedToWorld(World w)
{
worldWorld = (world) w;
counter3 = w.getCounter3();
choice = counter3.getCount();
}
private Counter2 theCounter2;
private Counter theCounter;
private int maximumcarrying=0;
private int score=0;
private int scorelevelone=150;//this sets the score
private int scoreleveltwo=150;
private boolean win=false;
private int targetscore; //may need to remove this
private int level=1;
private int passengersleft=4;
private int passengerscarrying=0;
//need to use this to set maximum bay size!!!!!!!!!!!
/**
* Act - do whatever the robot wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
scoretester();// Add your action code here.
}
//maybe try using a boolean to see whether the game has been won
public void setcounter(){ //this will decide whether to keep the counter at 150 or lower it to 130
if (level==2){
world worldWorld = (world) getWorld();
Counter counter = worldWorld.getCounter();
counter.bumpCount(-20);
scoretester();
}
else{
scoretester();
}
}world worldWorld = (world) getWorld();
world worldWorld = (world) w; counter3 = worldWorld.getCounter3();
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class robottrackslarge here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class robot extends Actor
{
public void addedToWorld(World w)
{
world worldWorld = (world) w;
counter3 = worldWorld.getCounter3(); //error displays "cannot find variable counter 3"
choice = counter3.getCount();
} // change line 14 to Counter counter3 = worldWorld.getCounter3();
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class robottrackslarge here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class robot extends Actor
{
public void addedToWorld(World w)
{
world worldWorld = (world) w;
Counter counter3 = worldWorld.getCounter3(); //incompatible types, found Counter3 but expected Counter
choice = counter3.getCount();
} //change line 14 to Counter3 counter3 = worldWorld.getCounter3();
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class robottrackslarge here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class robot extends Actor
{
public void addedToWorld(World w)
{
world worldWorld = (world) w;
Counter3 counter3 = worldWorld.getCounter3(); //fine now!
choice = counter3.getCount(); //cannot find symbol - variable choiceint choice = counter3.getCount();
public void scoring(){
//insert code here to check modification and then reduce accordingly
if (choice==1){ //it says it cannot find choice
world worldWorld = (world) getWorld();
Counter counter = worldWorld.getCounter();
counter.bumpCount(-5);
passengerpickuptester();
}
}private int choice;