Module hw06

Class SineMaker

java.lang.Object
provided.utils.valueGenerator.impl.SineMaker
All Implemented Interfaces:
ISineMaker

public class SineMaker extends Object implements ISineMaker
A utility class that can be used to create smoothly varying sinusoidal numerical data. Note that this is not a singleton class nor does it have static methods as its behavior depends on the minimum, maximum and delta values given to its constructor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    The amplitude of the sinusoidal output
    private double
    The amount that _theta is incremented each time, in radians.
    private double
    The midpoint of the min and max values.
    private double
    The current angle used to generate the current sinusoidal value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SineMaker​(double min, double max, double delta)
    The constructor takes several values to control the object's behavior.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns a different value each time it is called.
    int
    Same as getDblVal, but returns the result rounded to the nearest integer.

    Methods inherited from class java.lang.Object

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

    • _mid

      private double _mid
      The midpoint of the min and max values.
    • _ampl

      private double _ampl
      The amplitude of the sinusoidal output
    • _delta

      private double _delta
      The amount that _theta is incremented each time, in radians.
    • _theta

      private double _theta
      The current angle used to generate the current sinusoidal value. Initialized to produce the minimum value.
  • Constructor Details

    • SineMaker

      public SineMaker(double min, double max, double delta)
      The constructor takes several values to control the object's behavior.
      Parameters:
      min - The minimum and initial value to produce.
      max - The maximum value to produce.
      delta - The amount in radians that the generating angle is incremented each time
  • Method Details

    • getDblVal

      public double getDblVal()
      Description copied from interface: ISineMaker
      Returns a different value each time it is called. The value varies smoothly in a sinusoidal fashion, incrementing each time as per the above specified delta angle increase.
      Specified by:
      getDblVal in interface ISineMaker
      Returns:
      the next value as a double
    • getIntVal

      public int getIntVal()
      Description copied from interface: ISineMaker
      Same as getDblVal, but returns the result rounded to the nearest integer. Note that getDblVal and getIntVal are not independent as getIntVal merely calls getDblVal.
      Specified by:
      getIntVal in interface ISineMaker
      Returns:
      the next value as an int