You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trek-12/source/Trek-12/Models/Game/BestScore.cs

70 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Game
{
/// <summary>
/// This class represents the best score of a player.
/// </summary>
public class BestScore
{
/// <summary>
/// Initialize a new instance of the BestScore class.
/// </summary>
/// <param name="gamesPlayed">Number of games played by the new user</param>
/// <param name="score">Best score</param>
public BestScore(int gamesPlayed, int score)
{
GamesPlayed = gamesPlayed;
Score = score;
if (GamesPlayed < 0)
GamesPlayed = 0;
if (Score < 0)
Score = 0;
}
/// <summary>
/// Number of games played by the user.
/// </summary>
public int GamesPlayed { get; private set; }
/// <summary>
/// Best score of the player.
/// </summary>
private int _score;
public int Score
{
get
{
return _score;
}
private set
{
if (value > _score)
_score = value;
}
}
/// <summary>
/// Increment the number of games played by the user.
/// </summary>
public void IncrGamesPlayed()
{
GamesPlayed += 1;
}
/// <summary>
/// Update the best score of the player.
/// </summary>
/// <param name="newScore">New best score</param>
public void UpdateScore(int newScore)
{
Score = newScore;
}
}
}