Created
May 19, 2015 06:15
-
-
Save abuzarhamza/8ed2b7b6b9f2704a5a9e to your computer and use it in GitHub Desktop.
Java Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main program HelloNew.java | |
package greeting.hello; | |
import printer.Imachine; | |
public class HelloNew { | |
public static void main (String[] args ) { | |
Imachine machine = new PrinterTest(true,"test"); //Getting error at this line | |
machine.turnOn(); | |
} | |
} | |
//PrinterTest.java | |
package printer; | |
public class PrinterTest implements Imachine { | |
private boolean isOn; | |
private String modelNumber; | |
private Machine myMachine; | |
public PrinterTest(boolean isOn, String modelNumber) { | |
Machine myMachine = new Machine(isOn); | |
this.modelNumber = modelNumber; | |
} | |
@Override | |
public void turnOn() { | |
myMachine.turnOn(); | |
} | |
@Override | |
public void turnOff() { | |
myMachine.turnOff(); | |
} | |
@Override | |
public boolean isOn() { | |
return myMachine.isOn(); | |
} | |
@Override | |
public boolean isOff() { | |
// TODO Auto-generated method stub | |
return false; | |
} | |
} | |
//interface file Imachine.java | |
package printer; | |
public interface Imachine { | |
public void turnOn(); | |
public void turnOff(); | |
public boolean isOn(); | |
public boolean isOff(); | |
} | |
/* | |
Exception in thread "main" java.lang.Error: Unresolved compilation problem: | |
PrinterNew cannot be resolved to a type | |
at greeting.hello.HelloNew.main(HelloNew.java:11) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment