public class Solution {
public static void main(String[] args) {
Drink beer = new AlcoholicBeer();
System.out.println(beer.toString());
}
public interface Drink {
boolean isAlcoholic();
}
public static class AlcoholicBeer implements Drink{
@Override
public String toString() {
if (isAlcoholic()) {
return "Alcoholic beverage";
} else {
return "Non-alcoholic beverage";
}
boolean isAlcoholi(){
return "Alcoholic beverage";
}
}
please what is wrong
Under discussion
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Roman
25 February 2019, 13:35
1. You have a typo in isAlcoholic method name.
2. isAlcoholic method must be outside toString method.
0
Balen Asangbeh
25 February 2019, 15:23
Still doesn`t compile
0
Roman
26 February 2019, 08:32
show your new code please
0
Balen Asangbeh
26 February 2019, 08:55
0
Roman
26 February 2019, 11:12
You are trying to link the type of Drink to assign an object of type AlcoholicBeer.
0
Balen Asangbeh
26 February 2019, 12:15
ahh kk thanks Roman
0