I have to: **write a class encapsulating a sports game, which inherits from Game. Where the game has the following additional attributes: whether the game is a team or individual game, and whether the game can end in a tie.
**
I am not familiar with inheritance and am wondering if you guys could help get me on the right path. I have been reading about inheritance all day and just don't understand it. My question is: how to I build this project to incorporate inheritance, what can/should be inherited and how do you do it? Thanks
First class
public class Chap10Quest39
{
public static void main(String[] args)
{
Game tennis = new Chap10Quest39().new Game("individual","tie");
System.out.println(tennis + "\n");
System.out.print(tennis.getGameType() + " " + tennis.getWin() + " " + "\n");
}
}
Second
public class Game
{
//Instance Variables
private String gameType;
private String win;
public Game()
{
gameType = null;
win = null;
}
//Constructor
public Game(String gameType, String win)
{
this.gameType = gameType;
this.win = win;
}
//Accessors (Getters)
public String getGameType()
{
return gameType;
}
public String getWin()
{
return win;
}
//Mutators (Setters)
public void setGameType(String GameType)
{
this.gameType = gameType;
}
public void setWin(String win)
{
this.win = win;
}
// toString Method
public String toString()
{
return "Type: " + gameType + "; Win: " + win;
}
}