In short, what is a possible solution if I can't override this method?
I have tried removing the argument and instantiating at the begging with a constructor.
//////Cannot edit this//////
/**
* Scan interface
*/
interface Scan {
/**
* Scan a document
*/
public void scan();
}
//////Cannot edit this//////
//////Can Edit//////////////
/**
* HomeScanner class
*/
class HomeScanner implements Scan {
/**
* Prints "Scanning..."
*/
public void scan() {
System.out.println("Scanning...");
}
/**
* Prints what is bieng scanned
* @param isDoc tells if item being scanned is a document
*/
@Override
public void print(boolean isDoc) {
if(isDoc) {
System.out.print("Document ");
} else {
System.out.print("Book ");
}
scan();
}
}
//////Can Edit//////////////
After I create the class object I want to be able to call the method with the argument or an alternative with the same outcome.
What is the @Override above the print method for? Why don't you remove that one? – Knokko Just needed to remove it. Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.