Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class encapsulating a sports game, which inherits from Game. A sports ga

ID: 3825180 • Letter: W

Question

Write a class encapsulating a sports game, which inherits from Game. A sports game has the following additional attributes: whether the game is a team or individual game, and whether the game can end in a tie. Code the constructor and the toString method of the new class. You also need to include a client class to test your code.

The output should look like this:

Problems Javadoc Declaration O Console X Kterminated SportsGameClient Java Al ication] C:Program FilesVavalire1.8.0 111binliavaw.exe an 3, 2017 2:24:29 P description Soccer Is a team game: true Can end in a tie true description. 100 yards Is a team game false Can end in a tie true sgl and sg2 are not equal sgl and sg2 are now equal

Explanation / Answer

public class Game { public static void main(String[] args) { Question39 gm1 = new Question39(); System.out.println("Game type: "+ gm1.getGameType() + " " + "Can it tie: " + gm1.getCanTie()); } public Game() { } } Second Class public class SportsGame extends Game { public SportsGame() { super(); } public String toString() { String output ="hey"; return output; } //Accessors (Getters) public String getGameType() { Scanner scan = new Scanner(System.in); System.out.println("Enter number of players"); int players = scan.nextInt(); if (players > 2) { return "Team"; } else { if (players ==2) { return "Individual"; } else { return "N/A";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote