jizzed twice and feelin sleepy, but code needs porting so

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class TheShell extends DiSkillV2 {
    public Chobits shellChobit = new Chobits();
    private Chobits logicChobit;
    private Chobits hardwareChobit;
    private Hashtable<String,DiSkillV2> logicSkills = new Hashtable<>(); // all logic skills
    private Hashtable<String,DiSkillV2> hardwareSkills = new Hashtable<>(); // all hardware skills
    private AXCmdBreaker installer = new AXCmdBreaker("install");
    private AXCmdBreaker uninstaller = new AXCmdBreaker("abolish");
    private String temp = "";

    public TheShell(Sh_Brain b1) {
        this.logicChobit = b1.logicChobit;
        this.hardwareChobit = b1.hardwareChobit;
        shellChobit.addSkill(this);
    }

    public void addLogicSkill(String skillName, DiSkillV2 skill){
        logicSkills.put(skillName,skill);
    }
    public void addHardwareSkill(String skillName, DiSkillV2 skill){
        hardwareSkills.put(skillName,skill);
    }
    // shell methods
    private int sh_addSkill(String skillKey){
        if (!(logicSkills.containsKey(skillKey)||hardwareSkills.containsKey(skillKey))){
            return 0; // skill does not exist
        }
        // find the skill:
        if(logicSkills.containsKey(skillKey)){
            DiSkillV2 ref = logicSkills.get(skillKey);
            if(logicChobit.containsSkill(ref)){
                return 1; // logic skill already installed
            }
            logicChobit.addSkill(ref);
            return 2; // logic skill has been installed
        }
        DiSkillV2 ref = hardwareSkills.get(skillKey);
        if(hardwareChobit.containsSkill(ref)){
            return 3; // hardware skill already installed
        }
        hardwareChobit.addSkill(ref);
        return 4; // hardware skill has been installed
    }
    private int sh_removeSkill(String skillKey){
        if (!(logicSkills.containsKey(skillKey)||hardwareSkills.containsKey(skillKey))){
            return 0; // skill does not exist
        }
        if(logicSkills.containsKey(skillKey)){
            DiSkillV2 ref = logicSkills.get(skillKey);
            if(logicChobit.containsSkill(ref)){
                logicChobit.removeSkill(ref);
                return 1; // logic skill has been uninstalled
            }
            return 2; // logic skill is not installed
        }
        DiSkillV2 ref = hardwareSkills.get(skillKey);
        if(hardwareChobit.containsSkill(ref)){
            hardwareChobit.removeSkill(ref);
            return 3; // hardware skill has been uninstalled
        }
        return 4; // hardware skill is not installed
    }
    private void sh_removeAllSkills(){logicChobit.clearSkills();hardwareChobit.clearSkills();}
    @Override
    public void input(String ear, String skin, String eye) {
        if (ear.equals("remove all skills")){
            sh_removeAllSkills();
            return;
        }
        temp = installer.extractCmdParam(ear);
        if (!temp.isEmpty()){
            switch (sh_addSkill(temp)){
                case 0:
                    setVerbatimAlg(4, "skill does not exist");
                    break;
                case 1:
                    setVerbatimAlg(4, "logic skill already installed");
                    break;
                case 2:
                    setVerbatimAlg(4, "logic skill has been installed");
                    break;
                case 3:
                    setVerbatimAlg(4, "hardware skill already installed");
                    break;
                case 4:
                    setVerbatimAlg(4, "hardware skill has been installed");
                    break;
            }
            temp = "";
            return;
        }
        temp = uninstaller.extractCmdParam(ear);
        if (!temp.isEmpty()){
            switch (sh_removeSkill(temp)){
                case 0:
                    setVerbatimAlg(4, "skill does not exist");
                    break;
                case 1:
                    setVerbatimAlg(4, "logic skill has been uninstalled");
                    break;
                case 2:
                    setVerbatimAlg(4, "logic skill is not installed");
                    break;
                case 3:
                    setVerbatimAlg(4, "hardware skill has been uninstalled");
                    break;
                case 4:
                    setVerbatimAlg(4, "hardware skill is not installed");
                    break;
            }
            temp = "";
        }
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class Sh_Brain extends Brain {
    private TheShell shell = new TheShell(this);
    private String temp = "";
    public void addLogicSkill(String skillName, DiSkillV2 skill){
        shell.addLogicSkill(skillName, skill);
    }
    public void addHardwareSkill(String skillName, DiSkillV2 skill){
        shell.addHardwareSkill(skillName, skill);
    }

    public void setShell(TheShell shell) {
        // for using TheShell skill sub class objects with different input
        // method logic
        this.shell = shell;
    }

    @Override
    public void doIt(String ear, String skin, String eye) {
        temp = shell.shellChobit.think(ear, skin, eye);
        if(temp.isEmpty()){
            super.doIt(ear, skin, eye);
        }
        hardwareChobit.think(temp,skin,eye);
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
        Sh_Brain b1 = new Sh_Brain();
        b1.setShell(new TheShell(b1));
        // adding all skills:
        b1.addLogicSkill("hello world", new DiHelloWorld());
        b1.addHardwareSkill("output",new DiSysOut()); // this skill prints output
        // ^ shell filled with skills
        b1.doIt("install output", "","");
        b1.doIt("install hello world", "","");
        b1.doIt("hello", "","");
        b1.doIt("abolish hello world", "","");
        b1.doIt("hello", "","");
        System.out.println("skill reinstall:");
        b1.doIt("install hello world", "","");
        b1.doIt("hello", "","");
 

fukurou

the supreme coder
ADMIN
Java:
        ArrayList<String> tl = new ArrayList<>();
        tl.add("zero");tl.add("one");tl.add("two");tl.add("three");tl.add("four");tl.add("five");
        int c = 0;
        try {
            for (int i = 0; i < tl.size(); i++) {
                if (c == 3){
                    tl.remove(c);
                }
                c++;
                System.out.println(tl.get(i));
            }
        }
        catch(Exception e) {
            for (int i = c; i < tl.size(); i++) {
                System.out.println(tl.get(i));
            }
        }
 

fukurou

the supreme coder
ADMIN
Java:
public class Chosh extends Chobits{
    // Chobit shell: can install/uninstall skills using skills
    private int loopTracker = 0;
    @Override
    public String think(String ear, String skin, String eye) {
        loopTracker = 0;
        try {
            for (int i = 0; i < dClasses.size(); i++) {
                inOut(dClasses.get(i), ear, skin, eye);
            }
        }
        catch(Exception e) {
            for (int i = loopTracker; i < dClasses.size(); i++) {
                inOut(dClasses.get(i), ear, skin, eye);
            }
        }
        fusion.loadAlgs(noiron);
        return fusion.runAlgs(ear, skin, eye);
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
public class Chosh extends Chobits{
    // Chobit shell: can install/uninstall skills using skills
    private int loopTracker = 0;
    @Override
    public String think(String ear, String skin, String eye) {
        loopTracker = 0;
        try {
            for (int i = 0; i < dClasses.size(); i++) {
                inOut(dClasses.get(i), ear, skin, eye);
            }
        }
        catch(Exception e) {
            for (int i = loopTracker; i < dClasses.size(); i++) {
                inOut(dClasses.get(i), ear, skin, eye);
            }
        }
        fusion.loadAlgs(noiron);
        return fusion.runAlgs(ear, skin, eye);
    }
}
well, that was a wild goose chase :s14:
 

fukurou

the supreme coder
ADMIN
Python:
class TheShell(DiSkillV2):
    def __init__(self, b1: ShBrain):
        super().__init__()
        self.shellChobit: Chobits = Chobits()
        self._logicChobit: Chobits = b1.logicChobit
        self._hardwareChobit: Chobits = b1.hardwareChobit
        self.shellChobit.addSkill(self)


class ShBrain(Brain):
    pass
 

fukurou

the supreme coder
ADMIN
Python:
class TheShell(DiSkillV2):
    def __init__(self, b1: ShBrain):
        super().__init__()
        self.shellChobit: Chobits = Chobits()
        self.logicChobit: Chobits = b1.logicChobit
        self.hardwareChobit: Chobits = b1.hardwareChobit
        self.shellChobit.addSkill(self)
        self.logicSkills: [str, DiSkillV2] = {}
        self.hardwareSkills: [str, DiSkillV2] = {}
        self.installer: AXCmdBreaker = AXCmdBreaker("install")
        self.uninstaller: AXCmdBreaker = AXCmdBreaker("abolish")
        self.temp: str = ""

    def addLogicalSkill(self, skillName: str, skill: DiSkillV2):
        self.LogicalSkills[skillName] = skill

    def addHardwareSkill(self, skillName: str, skill: DiSkillV2):
        self.hardwareSkills[skillName] = skill

    # shell methods

    def sh_removeAllSkills(self):
        self.logicChobit.clearSkills()
        self.hardwareChobit.clearSkills()
 

fukurou

the supreme coder
ADMIN
Python:
class TheShell(DiSkillV2):
    def __init__(self, b1: ShBrain):
        super().__init__()
        self.shellChobit: Chobits = Chobits()
        self.logicChobit: Chobits = b1.logicChobit
        self.hardwareChobit: Chobits = b1.hardwareChobit
        self.shellChobit.addSkill(self)
        self.logicSkills: [str, DiSkillV2] = {}
        self.hardwareSkills: [str, DiSkillV2] = {}
        self.installer: AXCmdBreaker = AXCmdBreaker("install")
        self.uninstaller: AXCmdBreaker = AXCmdBreaker("abolish")
        self.temp: str = ""

    def addLogicalSkill(self, skillName: str, skill: DiSkillV2):
        self.LogicalSkills[skillName] = skill

    def addHardwareSkill(self, skillName: str, skill: DiSkillV2):
        self.hardwareSkills[skillName] = skill

    # shell methods
    def sh_addSkill(self, skillKey) -> int:
        if not (skillKey in self.logicSkills or skillKey in self.hardwareSkills):
            return 0  # skill does not exist
        # find the skill
        if skillKey in self.logicSkills:
            ref: DiSkillV2 = self.logicSkills[skillKey]
            if self.logicChobit.containsSkill(ref):
                return 1  # logic skill already installed
            self.logicChobit.addSkill(ref)
            return 2  # logic skill has been installed
        ref: DiSkillV2 = self.hardwareSkills[skillKey]
        if self.hardwareChobit.containsSkill(ref):
            return 3  # hardware skill already installed
        self.hardwareChobit.addSkill(ref)
        return 4  # hardware skill has been installed

    def sh_removeAllSkills(self):
        self.logicChobit.clearSkills()
        self.hardwareChobit.clearSkills()


class ShBrain(Brain):
    pass
 

fukurou

the supreme coder
ADMIN
Python:
class TheShell(DiSkillV2):
    def __init__(self, b1: ShBrain):
        super().__init__()
        self.shellChobit: Chobits = Chobits()
        self.logicChobit: Chobits = b1.logicChobit
        self.hardwareChobit: Chobits = b1.hardwareChobit
        self.shellChobit.addSkill(self)
        self.logicSkills: [str, DiSkillV2] = {}
        self.hardwareSkills: [str, DiSkillV2] = {}
        self.installer: AXCmdBreaker = AXCmdBreaker("install")
        self.uninstaller: AXCmdBreaker = AXCmdBreaker("abolish")
        self.temp: str = ""

    def addLogicalSkill(self, skillName: str, skill: DiSkillV2):
        self.LogicalSkills[skillName] = skill

    def addHardwareSkill(self, skillName: str, skill: DiSkillV2):
        self.hardwareSkills[skillName] = skill

    # shell methods
    def _sh_addSkill(self, skillKey) -> int:
        if not (skillKey in self.logicSkills or skillKey in self.hardwareSkills):
            return 0  # skill does not exist
        # find the skill
        if skillKey in self.logicSkills:
            ref: DiSkillV2 = self.logicSkills[skillKey]
            if self.logicChobit.containsSkill(ref):
                return 1  # logic skill already installed
            self.logicChobit.addSkill(ref)
            return 2  # logic skill has been installed
        ref: DiSkillV2 = self.hardwareSkills[skillKey]
        if self.hardwareChobit.containsSkill(ref):
            return 3  # hardware skill already installed
        self.hardwareChobit.addSkill(ref)
        return 4  # hardware skill has been installed

    def _sh_removeSkill(self, skillKey) -> int:
        if not (skillKey in self.logicSkills or skillKey in self.hardwareSkills):
            return 0  # skill does not exist
        if skillKey in self.logicSkills:
            ref: DiSkillV2 = self.logicSkills[skillKey]
            if self.logicChobit.containsSkill(ref):
                self.logicChobit.removeSkill(ref)
                return 1  # logic skill has been uninstalled
            return 2  # logic skill is not installed
        ref: DiSkillV2 = self.hardwareChobit[skillKey]
        if self.hardwareChobit.containsSkill(ref):
            self.hardwareChobit.removeSkill(ref)
            return 3  # hardware skill has been uninstalled
        return 4  # hardware skill is not installed

    def _sh_removeAllSkills(self):
        self.logicChobit.clearSkills()
        self.hardwareChobit.clearSkills()

    # Override
    def input(self, ear: str, skin: str, eye: str):
        if ear == "remove all skills":
            self._sh_removeAllSkills()
        self.temp = self.installer.extractCmdParam(ear)
        if self.temp:  # string is not empty?
            match (self._sh_addSkill(self.temp)):
                case 0:
                    self.setVerbatimAlg(4, "skill does not exist")
                case 1:
                    self.setVerbatimAlg(4, "logic skill already installed")
                case 2:
                    self.setVerbatimAlg(4, "logic skill has been installed")
                case 3:
                    self.setVerbatimAlg(4, "hardware skill already installed")
                case 4:
                    self.setVerbatimAlg(4, "hardware skill has been installed")
            self.temp = ""
            return
        self.temp = self.uninstaller.extractCmdParam(ear)
        if self.temp:  # string is not empty?
            match (self._sh_removeSkill(self.temp)):
                case 0:
                    self.setVerbatimAlg(4, "skill does not exist")
                case 1:
                    self.setVerbatimAlg(4, "logic skill has been uninstalled")
                case 2:
                    self.setVerbatimAlg(4, "logic skill is not installed")
                case 3:
                    self.setVerbatimAlg(4, "hardware skill has been uninstalled")
                case 4:
                    self.setVerbatimAlg(4, "hardware skill is not installed")
            self.temp = ""


class ShBrain(Brain):
    pass
 

fukurou

the supreme coder
ADMIN
Python:
class TheShell(DiSkillV2):
    def __init__(self, b1: ShBrain):
        super().__init__()
        self.shellChobit: Chobits = Chobits()
        self.logicChobit: Chobits = b1.logicChobit
        self.hardwareChobit: Chobits = b1.hardwareChobit
        self.shellChobit.addSkill(self)
        self.logicSkills: [str, DiSkillV2] = {}
        self.hardwareSkills: [str, DiSkillV2] = {}
        self.installer: AXCmdBreaker = AXCmdBreaker("install")
        self.uninstaller: AXCmdBreaker = AXCmdBreaker("abolish")
        self.temp: str = ""

    def addLogicalSkill(self, skillName: str, skill: DiSkillV2):
        self.logicSkills[skillName] = skill

    def addHardwareSkill(self, skillName: str, skill: DiSkillV2):
        self.hardwareSkills[skillName] = skill

    # shell methods
    def _sh_addSkill(self, skillKey) -> int:
        if not (skillKey in self.logicSkills or skillKey in self.hardwareSkills):
            return 0  # skill does not exist
        # find the skill
        if skillKey in self.logicSkills:
            ref: DiSkillV2 = self.logicSkills[skillKey]
            if self.logicChobit.containsSkill(ref):
                return 1  # logic skill already installed
            self.logicChobit.addSkill(ref)
            return 2  # logic skill has been installed
        ref: DiSkillV2 = self.hardwareSkills[skillKey]
        if self.hardwareChobit.containsSkill(ref):
            return 3  # hardware skill already installed
        self.hardwareChobit.addSkill(ref)
        return 4  # hardware skill has been installed

    def _sh_removeSkill(self, skillKey) -> int:
        if not (skillKey in self.logicSkills or skillKey in self.hardwareSkills):
            return 0  # skill does not exist
        if skillKey in self.logicSkills:
            ref: DiSkillV2 = self.logicSkills[skillKey]
            if self.logicChobit.containsSkill(ref):
                self.logicChobit.removeSkill(ref)
                return 1  # logic skill has been uninstalled
            return 2  # logic skill is not installed
        ref: DiSkillV2 = self.hardwareChobit[skillKey]
        if self.hardwareChobit.containsSkill(ref):
            self.hardwareChobit.removeSkill(ref)
            return 3  # hardware skill has been uninstalled
        return 4  # hardware skill is not installed

    def _sh_removeAllSkills(self):
        self.logicChobit.clearSkills()
        self.hardwareChobit.clearSkills()

    # Override
    def input(self, ear: str, skin: str, eye: str):
        if ear == "remove all skills":
            self._sh_removeAllSkills()
        self.temp = self.installer.extractCmdParam(ear)
        if self.temp:  # string is not empty?
            match (self._sh_addSkill(self.temp)):
                case 0:
                    self.setVerbatimAlg(4, "skill does not exist")
                case 1:
                    self.setVerbatimAlg(4, "logic skill already installed")
                case 2:
                    self.setVerbatimAlg(4, "logic skill has been installed")
                case 3:
                    self.setVerbatimAlg(4, "hardware skill already installed")
                case 4:
                    self.setVerbatimAlg(4, "hardware skill has been installed")
            self.temp = ""
            return
        self.temp = self.uninstaller.extractCmdParam(ear)
        if self.temp:  # string is not empty?
            match (self._sh_removeSkill(self.temp)):
                case 0:
                    self.setVerbatimAlg(4, "skill does not exist")
                case 1:
                    self.setVerbatimAlg(4, "logic skill has been uninstalled")
                case 2:
                    self.setVerbatimAlg(4, "logic skill is not installed")
                case 3:
                    self.setVerbatimAlg(4, "hardware skill has been uninstalled")
                case 4:
                    self.setVerbatimAlg(4, "hardware skill is not installed")
            self.temp = ""


class ShBrain(Brain):
    def __init__(self):
        super().__init__()
        self._shell: TheShell = TheShell(self)
        self._temp: str = ""

    def addLogicalSkill(self, skillName: str, skill: DiSkillV2):
        self._shell.addLogicalSkill(skillName, skill)

    def addHardwareSkill(self, skillName: str, skill: DiSkillV2):
        self._shell.addHardwareSkill(skillName, skill)

    def setShell(self, newShell: TheShell):
        #  for using TheShell skill subclass objects with different input
        #  method logic
        self._shell = newShell

    # Override
    def doIt(self, ear: str, skin: str, eye: str):
        self._temp = self._shell.shellChobit.think(ear, skin, eye)
        if not self._temp:  # is empty?
            super().doIt(ear, skin, eye)
            return
        self.hardwareChobit.think(self._temp, skin, eye)

Python:
if __name__ == '__main__':
    b1:ShBrain = ShBrain()
    b1.addLogicalSkill("hello world", DiHelloWorld())
    b1.addHardwareSkill("output", DiSysOut())
    b1.doIt("install output","","")
    b1.doIt("install hello world", "", "")
    b1.doIt("hello", "", "")
    b1.doIt("abolish hello world", "", "")
    b1.doIt("hello", "", "")
    b1.doIt("install hello world", "", "")
    b1.doIt("hello", "", "")

 
Top