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


battle programming a forum for elite programmers with extreme will power to sharpen their skills
 
HomeGallerySearchRegisterLog in
 

 added database capabilities

Go down 
AuthorMessage
kurosen
codding
codding
kurosen

Posts : 292
Join date : 2012-04-17

added database capabilities Empty
PostSubject: added database capabilities   added database capabilities EmptyTue Jan 26, 2021 4:28 pm

the grimoirememento class of the kokoro class
now has a save and a load function.

any new skill that uses the kokoro class such as DiSkill and TheSkill can use DB
capabilities to save and load.

her is the 1st example use : DiSayer class (java cls)
example use : honey say pen
output : pen

honey say something
output : pen
it doesn't matter if you turned off the app and reopened. she remembers.

Code:
package com.yotamarker.lgkotlin1;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DiSayer extends  DISkill{
    private int times;
    private String param;
    public DiSayer(Kokoro kokoro) {
        super(kokoro);
        this.times = 1;
        this.param = "";
    }

    @Override
    public void input(String ear, String skin, String eye) {
        if(ear.contains("say something")){
            this.param = kokoro.grimoireMemento.simpleLoad("something");
            return;
        }
        int foo = 1;
        String myString = regexChecker("(\\d+)(?= times)", ear);
        String toSay = regexChecker("(?<=say)(.*)(?=\\d)", ear);
        if (myString != "") {
            foo = Integer.parseInt(myString);
        } else {
            toSay = regexChecker("(?<=say)(.*)", ear);
        }
        this.param = toSay;
        this.times = foo;
    }

    @Override
    public void output(Neuron noiron) {
        if (!param.isEmpty()) {
            this.kokoro.grimoireMemento.simpleSave("something",param);
            AbsAlgPart itte = new APSay(this.times, this.param);
            String representation = "say " + param;
            if (this.times > 1) {
                representation += " " + this.times + " times";
            }
            ArrayList<AbsAlgPart> algParts1 = new ArrayList<>();
            algParts1.add(itte);
            Algorithm algorithm = new Algorithm("say", representation, algParts1);
            noiron.algParts.add(algorithm);
        }
    }
    public static String regexChecker(String theRegex, String str2Check) {
        Pattern checkRegex = Pattern.compile(theRegex);
        Matcher regexMatcher = checkRegex.matcher(str2Check);
        while (regexMatcher.find()) {
            if (regexMatcher.group().length() != 0) {
                return regexMatcher.group().trim();
            }
        }
        return "";
    }
}

battle programming
Back to top Go down
 
added database capabilities
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Jump to: