Class DecimalDigitsNSG

java.lang.Object
it.unimi.di.prog2.h15.DecimalDigitsNSG

public class DecimalDigitsNSG extends Object
A class representing decimal digits of a long, endowed with a non zero digits iterator, based on the nested static NonZeroDigitsGeneratorNS class.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    A nested static class implementing the genrator.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
    The number whose digits are represented by this class.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DecimalDigitsNSG(long number)
    Creates a new instance representing the digits of the given number.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    digit(int power)
    Returns the digit corresponding to the given power of 10.
    Returns a generator on from the least significant to the most significant non zero digits.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • number

      private final long number
      The number whose digits are represented by this class.
  • Constructor Details

    • DecimalDigitsNSG

      public DecimalDigitsNSG(long number)
      Creates a new instance representing the digits of the given number.
      Parameters:
      number - the number.
  • Method Details

    • digit

      public int digit(int power)
      Returns the digit corresponding to the given power of 10.
      Parameters:
      power - the power.
      Returns:
      the corresponding digit.
    • nonZeroDigits

      public Iterator<Integer> nonZeroDigits()
      Returns a generator on from the least significant to the most significant non zero digits.
      Returns:
      the generator.