battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeSearchRegisterLog in
Post new topic   Reply to topicShare
 

 APImprintMaster form alg part for imprinting chobits master

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 372
Join date : 2011-08-02

APImprintMaster form alg part for imprinting chobits master Empty
PostSubject: APImprintMaster form alg part for imprinting chobits master   APImprintMaster form alg part for imprinting chobits master EmptyThu Sep 26, 2019 7:47 am

Code:
package chobit;

import java.util.ArrayList;

public class APImprintMaster extends AbsAlgPart {
   // todo : handle inputs regexes
   ArrayList<String> form = new ArrayList<>();
   int mode = 0;
   int index = 0;
   String input = "";
   Boolean isCompleted = false;
   String curResult = "";
   Person master;

   public APImprintMaster(Person master) {
      super();
      form.add("nice to meet you, and what would your name be");
      form.add("are you my master");
      form.add("I will input your name");
      form.add("what is your skill");
      form.add("what is your profession");
      form.add("what is your phone number");
      form.add("what is your email address");
      form.add("which is your favorite jutsu");
      form.add("soul spark engaged");
      this.master = master;
   }

   public void AddToform(String... strs) {
      for (String i : strs) {
         //
      }
   }

   @Override
   public String action(String ear, String skin, String eye) {
      String result = "";
      switch (mode) {
      case 0:
         result = form.get(index);
         curResult = result;
         if (result.contains("what") || result.contains("which is") || result.contains("please")
               || result.contains("are you")) {
            mode = 2;
         }
         else {
            index++;
         }
         break;
      case 2:
         if (!ear.isEmpty()) {
            mode = 3;
            input = ear;
         }
         if (form.get(index).contains("are you")) {
            mode = 4;
            input = ear;
         }
         break;
      case 3:
         result = input + " yes";
         mode = 4;
         break;
      case 4:
         if (ear.contains("yes")) {
            mode = 0;
            imprint();
            index++;
         }
         if (ear.contains("no")) {
            mode = 0;
         }
         break;
      default:
         break;
      }
      if (index == form.size()) {
         isCompleted = true;
         index--;
      }
      return result;
   }

   public void imprint() {
      switch (curResult) {
      case "nice to meet you, and what would your name be":
         master.setName(input);
         break;
      case "what is your skill":
         master.setSkill(input);
         break;
      case "what is your profession":
         master.setProfession(input);
         break;
      case "what is your phone number":
         master.setPhone(input);
         break;
      case "what is your email address":
         master.setEmail(input);
         break;
      case "which is your favorite jutsu":
         master.setJutsu(input);
         break;
      default:
         break;
      }
   }

   @Override
   public Boolean itemize() {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public enumFail failure(String input) {
      // TODO Auto-generated method stub
      return enumFail.ok;
   }

   @Override
   public Boolean completed() {
      // TODO Auto-generated method stub
      return isCompleted;
   }

   @Override
   public AbsAlgPart clone() {
      // ***might glich, clone person ?
      return new APImprintMaster(this.master);
   }

}

chii

_________________
MB over and out emp it up
Back to top Go down
 
APImprintMaster form alg part for imprinting chobits master
Back to top 
Page 1 of 1

Permissions in this forum:You can reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Post new topic   Reply to topicJump to: