namespace PetsAndFleas; /// /// Represents a cat /// public sealed class Cat : Pet { private bool _isOnTree; /// /// The number of trees the cat has climbed /// public int TreesClimbed { get; private set; } public Cat() { PrintCtorInfo("cat"); } /// /// Tries to climb a tree /// /// True if climbing was successful, false if cat is already on a tree public bool ClimbOnTree() { if (_isOnTree) { return false; } TreesClimbed++; _isOnTree = true; return true; } /// /// Tries to climb a tree /// /// True if climbing was successful, false if cat is not on a tree public bool ClimbDown() { if (!_isOnTree) { return false; } _isOnTree = false; return true; } /// /// Returns a string representation of the cat /// /// The string that represents the cat public override string ToString() => "I'm a cat"; }