Create a class named Game. Include auto-implemented properties
for the game's name and maximum number of players.
Also, include a ToString() Game method that overrides the
Object class's ToString() method and returns a string that
contains the name of the class (using GetType()), the name
of the Game, and the number of players. Create a child class
named GameWithTimeLimit that includes an auto-implemented
integer property for the game's time limit in minutes.
Write a program that instantiates an object of each class and
demonstrates all the methods
Did I solve the problem?
class Program
{
static void Main(string[] args)
{
Game something = new Game();
GameWithTimeLimit somethingTwo = new GameWithTimeLimit();
something.GameName = "Let em ride";
something.MaxNumPlayers = 4;
somethingTwo.GameName = " Blackjack ";
somethingTwo.GameTimeLimit = 60;
somethingTwo.MaxNumPlayers = 5;
Console.WriteLine(something.GameName);
Console.WriteLine(something.MaxNumPlayers);
Console.WriteLine(somethingTwo.GameName);
Console.WriteLine(somethingTwo.GameTimeLimit);
Console.WriteLine(somethingTwo.MaxNumPlayers);
}
==================================================
class Game
{
public string GameName { get; set; }
public int MaxNumPlayers { get; set; }
public override string ToString()
{
return (GetType()+":"+GameName+":"+":"+MaxNumPlayers);
}
=================================================
class GameWithTimeLimit : Game
{
public int GameTimeLimit { get; set; }
}