Class Problem

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long end
      The time in nanoseconds when the solving process got finished.
      protected int number
      The number of this problem.
      private long start
      The time in nanoseconds when the solving process got started.
      protected java.lang.String title
      The title of this problem.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Problem​(int num, java.lang.String tit)
      A simple base constructor to set the given number and title
    • Method Summary

      Modifier and Type Method Description
      void finish()
      Standard implementation of the finishing method.
      java.lang.String getResult()
      This method should be called by an external execution process.
      double getRuntime​(int p)
      Calculates the runtime needed to solve this problem as difference of end and start.
      void prepare()
      Standard implementation of the preparing method.
      private void start()
      Stores the current system's time in nanoseconds into start.
      private void stop()
      stores the current system's time nanoseconds into end.
      java.lang.String toString()
      It just returns the number of this problem as string representation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface net.n1da.dev.euler.core.Solvable

        solve
    • Field Detail

      • number

        protected int number
        The number of this problem.
      • title

        protected java.lang.String title
        The title of this problem.
      • start

        private long start
        The time in nanoseconds when the solving process got started.
      • end

        private long end
        The time in nanoseconds when the solving process got finished.
    • Constructor Detail

      • Problem

        protected Problem​(int num,
                          java.lang.String tit)
        A simple base constructor to set the given number and title
        Parameters:
        num - - the number of this problem
        tit - - the title of this problem
    • Method Detail

      • getResult

        public java.lang.String getResult()
        This method should be called by an external execution process. It does internally the following steps by calling the necessary methods:
        1. prepare the problem solving
        2. start the internal timer
        3. solve the problem
        4. stop() the internal timer
        5. finish the solving process
        Finally the string given by Solvable.solve() is returned.
        Returns:
        the result of this problem as string
      • getRuntime

        public double getRuntime​(int p)
        Calculates the runtime needed to solve this problem as difference of end and start. Since the time is stored in nanoseconds a divider - a power of 1.000 - can be used.
        Parameters:
        p - - the power of 1000 to transform the time (use 0 to get nanoseconds)
        Returns:
        - the runtime of the execution in the wanted format
      • start

        private void start()
        Stores the current system's time in nanoseconds into start.
      • stop

        private void stop()
        stores the current system's time nanoseconds into end.
      • prepare

        public void prepare()
        Standard implementation of the preparing method. It just prints an info with the number and title. It can be overridden by subclasses if needed.
        Specified by:
        prepare in interface Solvable
      • finish

        public void finish()
        Standard implementation of the finishing method. It just prints an info with the number. It can be overridden by subclasses if needed.
        Specified by:
        finish in interface Solvable
      • toString

        public java.lang.String toString()
        It just returns the number of this problem as string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the number as string