Implemented the functions
This commit is contained in:
parent
2d9718e247
commit
5ebee894e7
2 changed files with 73 additions and 17 deletions
|
|
@ -4,18 +4,44 @@ namespace DigitSequence;
|
|||
|
||||
public sealed class Digits(int number) : IEnumerable<int>, IComparable<Digits>
|
||||
{
|
||||
// TODO
|
||||
//private readonly int _number;
|
||||
private readonly int _number = Math.Abs(number);
|
||||
|
||||
/// <summary>
|
||||
/// Compares to another digit
|
||||
/// </summary>
|
||||
/// <param name="other">The other digit</param>
|
||||
/// <returns>The default compared value</returns>
|
||||
public int CompareTo(Digits? other)
|
||||
{
|
||||
// TODO
|
||||
return -1;
|
||||
if (other == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(this, other))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _number.CompareTo(other._number);
|
||||
}
|
||||
|
||||
public IEnumerator<int> GetEnumerator() => null!; // TODO
|
||||
/// <summary>
|
||||
/// Gets the enumerator of type <see cref="int"/>
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="IEnumerator"/> of type <see cref="int"/></returns>
|
||||
public IEnumerator<int> GetEnumerator() => new DigitEnumerator(number);
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => null!; // TODO
|
||||
/// <summary>
|
||||
/// Gets the enumerator as an <see cref="object"/> of type <see cref="IEnumerator"/>
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="IEnumerator"/></returns>
|
||||
// I'm gonna be a wikipedia author with that many references xD
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
public override string ToString() => null!; // TODO
|
||||
}
|
||||
/// <summary>
|
||||
/// The overriden Method to get the <see cref="string"/> representation of the current object
|
||||
/// </summary>
|
||||
/// <returns>The values of <see cref="Digits"/> in a <see cref="string"/> format</returns>
|
||||
public override string ToString() => _number.ToString();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue