Class DecimalDigits

java.lang.Object
it.unimi.di.prog2.h15.dd.DecimalDigits

public class DecimalDigits extends Object
A class representing decimal digits of a long.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DecimalDigits(long number)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    digit(int power)
    Returns the digit corresponding to the given power of 10.
    static void
    main(String[] args)
    This method serves the only purpose to show an usage example of this class.

    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
  • Constructor Details

    • DecimalDigits

      public DecimalDigits(long 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.
    • main

      public static void main(String[] args)
      This method serves the only purpose to show an usage example of this class.

      It prints the requested digit of a given number.

      Parameters:
      args - the first parametr is the number, the second the poisition of the digit to be printed.