SHARE
TWEET

Untitled

advictoriam Jan 31st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SpinningDiskDevice
  2. {
  3.    private int lastInput;
  4.    private int transitions;
  5.  
  6.    /**
  7.       Constructs a spinning disk device.
  8.    */
  9.    public SpinningDiskDevice()
  10.    {
  11.       lastInput = 0;
  12.       transitions = -1;
  13.    }
  14.  
  15.    /**
  16.       Processes a new input
  17.       @param input 0 or 1
  18.    */
  19.    public void add(int input)
  20.    {
  21.       if(input != lastInput)
  22.       {
  23.         lastInput = input;
  24.         transitions++;
  25.       }
  26.    }
  27.  
  28.    /**
  29.       Gets the number of transitions observed since this
  30.       device has been constructed.
  31.    */
  32.    public int getTransitions()
  33.    {
  34.       return transitions;
  35.    }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top