namespace PetsAndFleas;
///
/// Abstract class for pets
///
public abstract class Pet
{
///
/// Next available pet ID
///
public static int NextPetId { get; private set; }
///
/// The unique pet ID
///
public int PetId { get; }
///
/// The remaining bites for this pet
///
public int RemainingBites { get; private set; } = 100;
///
/// Initializes a new class
///
protected Pet()
{
NextPetId++;
PetId = NextPetId;
}
///
/// Reduces the remaining bites for this pet
///
/// Number of bites to take
/// The actual number of bites taken
public int GetBitten(int bites)
{
if (bites <= 0)
{
return 0;
}
int actualBites = Math.Min(bites, RemainingBites);
RemainingBites -= actualBites;
return actualBites;
}
///
/// Prints information about the constructor
///
/// The type of pet being created
protected static void PrintCtorInfo(string petType)
{
Console.WriteLine($"Creating a new {petType}");
}
}