+ 3

What is the problem?

I cant solve the abstract class in Java Intermediate

24th Jun 2023, 7:16 AM
P33pe
P33pe - avatar
8 Réponses
+ 5
Don't share the code like this, please see this post https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
24th Jun 2023, 7:52 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 5
Please post the task description as well. Not everyone has it in their memory. // play method should print "Sink all ships." public void play() { System.out.println("Sink all battleships."); If you look at the comment (line with //) and the print statement, you don't have the exact same wording i.e ships =/= battleships
24th Jun 2023, 8:12 AM
Ausgrindtube
Ausgrindtube - avatar
+ 5
Pat it's ok, no problem
24th Jun 2023, 12:18 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 4
Great you have the answer! We all make those same mistakes. Happy learning!
24th Jun 2023, 3:21 PM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Hahaha 😂 That's the reason why I can't solve. Thx very much !!!!
24th Jun 2023, 11:27 AM
P33pe
P33pe - avatar
+ 3
Sorry Sakshi I've posted my first question on sololearn. Next time I do it by the regular way 👍
24th Jun 2023, 11:34 AM
P33pe
P33pe - avatar
+ 1
class Main { public static void main(String[] args) { //do not touch this code Monopoly monopoly = new Monopoly(); Chess chess = new Chess(); Battleships battleships = new Battleships(); monopoly.play(); chess.play(); battleships.play(); } } abstract class Game { protected String name; abstract String getName(); abstract void play(); } class Monopoly extends Game { //give "Monopoly" name to game public void setName (String n){ this.name = n; } public String getName() { return name; } // play method should print "Buy all property." public void play() { System.out.println("Buy all property."); } } class Chess extends Game { //give "Chess" name to game public void setName (String n){ this.name = n; } public String getName() { return name; } // play method should print "Kill the enemy king." public void play() { System.out.println("Kill the enemy
24th Jun 2023, 7:17 AM
P33pe
P33pe - avatar
+ 1
} } class Battleships extends Game { //give "Battleships" name to game public void setName (String n){ this.name = n; } public String getName() { return name; } // play method should print "Sink all ships." public void play() { System.out.println("Sink all battleships."); } }
24th Jun 2023, 7:19 AM
P33pe
P33pe - avatar