Need help with java abstract class lesson
Can't seem to get passed the java abstract lesson on java intermediate course. What it wants as output is unclear and also locked. I have looked at the solution it gives you. Still doesn't work. All the main seems to call is the play() method for each game. I have tested my code and it output'd exactly that. Also tested my code to make sure name is given to game class as it asks, that also worked. I there something I'm missing? This is my code... 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.getName(); chess.getName(); battleships.getName(); monopoly.play(); chess.play(); battleships.play(); } } abstract class Game { public String name; abstract String getName(); abstract void play(); } class Monopoly extends Game { //give "Monopoly" name to game String getName() { name = "Monopoly"; return name; } // play method should print "Buy all property." void play() { System.out.println("Buy all property.") ; } } class Chess extends Game { //give "Chess" name to game String getName() { name = "Chess"; return name; } // play method should print "Kill the enemy king." void play() { System.out.println("Kill the enemy king."); } } class Battleships extends Game { //give "Battleships" name to game String getName() { name = "Battleships"; return name; } // play method should print "Sink all ships." void play() { System.out.println("Sink all ships."); } }