Screen Shot 2012-11-01 at 4.45.22 PM.png
Errors in order:
Syntax error on tokens, delete these tokens
Syntax error on tokens, Expression expected instead
Syntax error on tokens, Expression expected instead
Syntax error on tokens, delete these tokens
This is my worker class:
package HW07;
//Bulb.java
public class Bulb
{
//Instance Data
private boolean bulbLit;
//Constructor
public Bulb (boolean bulbLitIn)
{
bulbLit = bulbLitIn;
}
//bulb setter off
public void turnOff()
{
bulbLit = false;
}
//bulb setter on
public void turnOn ()
{
bulbLit = true;
}
public String toString()
{
String result = ;
result += This bulb is currently ;
if(bulbLit)
result += on;
else
result += off
return result;
}
}
This is my driver class:
package HW07;
public class HW07
{
public static void main (String[] args)
{
//Instantiate 2 bulb objects.
Bulb bulb1 = new Bulb (false);
Bulb bulb2 = new Bulb (false);
//Bulb1 is turned on
bulb1.turnOn();
//Print out each bulbs original information.
System.out.println ("Bulb 1: " +bulb1);
System.out.println ("Bulb 2: " +bulb2);
//Turn off bulb1 turn on bulb2
bulb1.turnOff();
bulb2.turnOn();
//Print out each bulbs original information.
System.out.println ("Bulb 1: " +bulb1);
System.out.println ("Bulb 2: " +bulb2);
}
}
This is the output:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on tokens, delete these tokens
Syntax error on tokens, Expression expected instead
Syntax error on tokens, Expression expected instead
Syntax error on tokens, delete these tokens
at HW07.Bulb.toString(Bulb.java:35)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java: 115)
at HW07.HW07.main(HW07.java:20)