-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debouncing boolean #12
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,6 @@ | |||
package lib; | |||
|
|||
public interface DebouncedBoolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Called DebouncedBoolean, not DebouncingBoolean
* @param windowSize sets size for the queue | ||
* @param x boolean passed to initialize the queue | ||
*/ | ||
public DebouncingBoolean(int windowSize, boolean x){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter should be named default
public DebouncingBoolean(int windowSize, boolean x){ | ||
this.windowSize = windowSize; | ||
queue = new LinkedList<Boolean>(); | ||
while(queue.size() < windowSize){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize count to +windowSize or -windowSize depending on default
*/ | ||
public void add(boolean b){ | ||
if (b){ | ||
queue.removeFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this out of the if, but you should also change count
public class DebouncingBoolean implements DebouncedBoolean{ | ||
private static LinkedList<Boolean> queue; | ||
private static int windowSize; | ||
private boolean count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an int
keeping track of how many true or false values have been added
/** | ||
* @return count boolean that determines if the queue is true or false | ||
*/ | ||
public boolean get(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eturn count > 0;
Debouncing Boolean class
Deboucing Boolean test case