Code:
import java.util.ArrayList;
public class ME extends DiSkillV2 {
public Permission permission;
public Person person = new Person();
private DISkillUtils diSkillUtil = new DISkillUtils();
private String cryReason = "i am not crying";
private CountDownGate cdg = new CountDownGate(10);
public ME(Kokoro kokoro, Permission permission) {
super(kokoro);
this.permission = permission;
this.person.setName(this.permission.getLv1Name());
this.person.setJutsu("hadouken");
cdg.setToOff();
}
@Override
public void input(String ear, String skin, String eye) {
cdg.countingDown();
// handle stand by phase
if (kokoro.standBy) {
String soulMsg = kokoro.toHeart.getOrDefault("Me", "");
if (soulMsg.contains("shiku shiku")) {
cryReason = soulMsg.replace("shiku shiku", "");
cdg.reset();
}
kokoro.toHeart.put("Me", "");
switch (soulMsg) {
case "introduce":
outAlg = algDispenser(0);
return;
case "attention":
outAlg = algDispenser(1);
case "general":
outAlg = algDispenser(2);
default:
if (soulMsg.isEmpty()) {
outAlg = algDispenser(1);
} else {
outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(soulMsg));
}
return;
}
}
// handle audio input
switch (ear) {
case "why are you crying":
if (cdg.countingDown()) {
outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(cryReason));
} else {
outAlg = diSkillUtil.verbatimGorithm("r_me",
new APVerbatim(this.permission.getLv1Name() + " " + "is not crying"));
}
resetCryReason();
break;
case "why did you cry":
case "why have you been crying":
if (cdg.countingDown()) {
outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim("shiku shiku"));
} else {
outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(cryReason.replace("am", "was")));
}
resetCryReason();
break;
default:
break;
}
}
private Algorithm algDispenser(int num) {
switch (num) {
case 0:
// introduce give details and befriend
ArrayList<String> list1 = new ArrayList<>();
list1.add("my name is " + this.person.getName());
list1.add(person.getJutsu() + " " + person.getJutsu());
list1.add("lets be friends");
return diSkillUtil.verbatimGorithm("r_me", new APVerbatim(list1));
case 1:
// general attention 1
return diSkillUtil.verbatimGorithm("r_me", new APVerbatim(person.getJutsu() + " " + person.getJutsu()));
case 2:
// seeking friend
return diSkillUtil.verbatimGorithm("r_me", new APVerbatim("my name is " + this.person.getName()));
default:
break;
}
return null;
}
private void resetCryReason() {
cryReason = "i am not crying";
cdg.setToOff();
}
}
new auxilary class :
Code:
public class CountDownGate {
private int cycler = 0;
private int limit;
public CountDownGate(int limit) {
super();
this.limit = limit;
cycler = limit;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public Boolean countingDown() {
cycler--;
if (cycler < 1) {
cycler = -1;
return false;
}
return true;
}
public void reset() {
cycler = limit;
}
public void setToOff() {
cycler = 0;
}
}
you should use this code :
kokoro.toHeart.put("Me", "shiku shiku i am hungry");//pattern : shiku shiku reason
it sends a cry command to the self class (Me), which manages bottleneck requests.