Interfaces
Implementing Interfaces
public interface UseComputer
{
/* Notice how we end our method signatures with semi-colons `;`
* and not curly brackets
*/
public void pressKey(Key keyPressed);
public void clickMouse(MouseEvent mouse);
public void shutDown();
public void startUp();
}public class GeneralUser implements UseComputer
{
private boolean isShuttingDown = false;
private boolean isStartingUp = false;
public void pressKey(Key keyPressed)
{
return keyPressed;
}
public void clickMouse(MouseEvent mouse)
{
return mouse;
}
public void shutDown()
{
isShuttingDown = true;
isStartingUp = false;
}
public void startUp()
{
isShuttingDown = false;
isStartingUp = true;
}
}Comparable Interface
Last updated