import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Square2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Square2 extends Actor
{
private GreenfootImage image1;
private GreenfootImage image2;
public String num1 = Greenfoot.ask("What is number 1?");
public String num2 = Greenfoot.ask("What is number 2?");
public String num3 = Greenfoot.ask("What is number 1 plus number 2 ?");
public String Sum = num1 + num2;
public void Square()
{
image1= new GreenfootImage("green.png");
image2= new GreenfootImage("yellow.png");
}
/**
* Act - do whatever the Square2 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (num3==Sum){
setImage(image1);
}
}
}
It supposed to turn green when if they are qual to each other but its not