battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

the LivinGrimoire Artificial General Intelligence software design pattern forum

description On/Off Boolean Gate Empty On/Off Boolean Gate

more_horiz
🎉 **Introducing the revolutionary On/Off Boolean Gate!** 🎉

Are you a developer working with Java, Python, or Swift? Do you need a reliable way to manage states in your application? Look no further! Our On/Off Boolean Gate is the perfect solution for you.

**Why choose our On/Off Boolean Gate?**

1. **Versatility**: Whether you're coding in Java, Python, or Swift, our Boolean Gate has got you covered. It's designed to work seamlessly across these languages, providing you with the flexibility you need.

2. **Control**: With our Boolean Gate, you're in charge. You can easily turn the gate on or off based on your input. It's all about giving you control over your application's behavior.

3. **Timed Auto-Close**: One of the standout features of our Boolean Gate is its ability to automatically close after a specified time period. Set it to remain open for N minutes, and it will automatically close afterwards. No need to worry about manually managing the state.

4. **Ideal for Burst Modes**: If you're coding burst modes or need to set states temporarily, our Boolean Gate is a perfect fit. It allows you to manage temporary states without any hassle.

5. **Simplicity**: Despite its powerful features, our Boolean Gate is incredibly easy to use. It's all about making your coding experience as smooth and straightforward as possible.

So why wait? Give our On/Off Boolean Gate a try today and experience the difference it can make in your coding projects! 💻

Code:

package AXJava;

import LivinGrimoire.TimeGate;

public class OnOffSwitch {
    private Boolean mode = false;
    private TimeGate timeGate = new TimeGate(5);
    private Responder on = new Responder("on","talk to me");
    private Responder off = new Responder("off","stop","shut up", "shut it","whatever","whateva");

    public void setPause(int minutes) {
        this.timeGate.setPause(minutes);
    }

    public void setOn(Responder on) {
        this.on = on;
    }

    public void setOff(Responder off) {
        this.off = off;
    }

    public Boolean getMode(String ear){
        if (on.responsesContainsStr(ear)){
            timeGate.openGate();
            mode = true;
            return true;
        } else if (off.responsesContainsStr(ear)) {
            timeGate.close();
            mode = false;
        }
        if (timeGate.isClosed()){mode = false;}
        return mode;
    }
}

description On/Off Boolean Gate EmptyRe: On/Off Boolean Gate

more_horiz
example use:
OnOffSwitch onOffSwitch = new OnOffSwitch();
System.out.println(onOffSwitch.getMode(""));
System.out.println(onOffSwitch.getMode("on"));
System.out.println(onOffSwitch.getMode("off"));
System.out.println(onOffSwitch.getMode("turn on"));
System.out.println(onOffSwitch.getMode("off"));
System.out.println(onOffSwitch.getMode("moon"));
System.out.println(onOffSwitch.getMode("on"));
System.out.println(onOffSwitch.getMode("test"));
System.out.println(onOffSwitch.getMode("test2"));

false
true
false
false
false
false
true
true
false // false after 5 minutes, true under 5 minutes
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply