5.2k views
5 votes
EX 7.15 Imagine a game in which some game elements can be broken by the player and others can’t. Create an interface called Breakable that has a method called break that takes no parameters and another called broken that returns a boolean result indicating whether that object is currently broken.

User Sikora
by
3.9k points

1 Answer

1 vote

Answer:

public interface Breakable

{

public void break();

public boolean broken();

}

Step-by-step explanation:

Here is the interface named Breakable

This interface has two functions break() and broken()

break() method has no parameters

broken() method returns a boolean result. As you can see boolean keyword is written before the method name which basically return true or false.

User Dafen
by
3.8k points