Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Debouncing boolean #12

wants to merge 23 commits into from

Conversation

KevinHenriquez
Copy link
Contributor

  • Debouncing Boolean class

  • Deboucing Boolean test case

@@ -0,0 +1,6 @@
package lib;

public interface DebouncedBoolean {
Copy link
Contributor

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){
Copy link
Contributor

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){
Copy link
Contributor

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();
Copy link
Contributor

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;
Copy link
Contributor

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(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eturn count > 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants