language : java
stage : dev
main class :
number getter
where :
Mcode
who extends what class
hadoshouryuengekimahou ken
stage : dev
main class :
Code:
package filter;
import java.util.Arrays;
import java.util.List;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Numerize numerize = new Numerize();
System.out.println(numerize.filter("hi1and666then3"));
System.out.println(Arrays.toString(numerize.getAllWords()));
System.out.println(Arrays.toString(numerize.getNumArr()));
System.out.println(numerize.getAllWords().length + "");
PlaceFilter pFilter = new PlaceFilter("go to the place at the park");
System.out.println(pFilter.getKelet());
System.out.println(pFilter.get1stPlace());
// what titan
WhatFilter wFilter = new WhatFilter();
wFilter.setWhats("turn on switch");
List<String> result = wFilter.getWhats();
System.out.println(result.toString());
Who whoFilter = new Who("moti turn on switch");
// whoFilter.setWho("moti turn on switch");
List<String> result2 = whoFilter.getWho();
System.out.println(result2.toString());
}
}
number getter
Code:
package filter;
public class Numerize {
final static private String allnums = "0123456789";
String proccessed = "";
String numsArr = "";
public String filter(String s1) {
char[] arr = s1.toCharArray();
String result = "";
Boolean spliter = true;
for (char ot : arr) {
if (allnums.contains(ot + "")) {
spliter = true;
result += ot;
numsArr += ot;
} else {
if (spliter) {
numsArr += " ";
proccessed += " ";
spliter = false;
}
proccessed += ot + "";
}
}
proccessed = proccessed.trim();
numsArr = numsArr.trim();
return result;
}
public String[] getAllWords() {
return proccessed.split(" ");
}
public String[] getNumArr() {
return numsArr.split(" ");
}
}
where :
Code:
package filter;
public class PlaceFilter {
private String[] placeMark = { "at " };
private String kelet = "";
private String spChar = "A";
public PlaceFilter(String input) {
this.kelet = input;
for (String marker : placeMark) {
this.kelet = this.kelet.replaceAll(marker, "A");
}
}
public String getKelet() {
return kelet;
}
public void setKelet(String kelet) {
this.kelet = kelet;
}
public String get1stPlace() {
char[] arr = kelet.toCharArray();
boolean bool1 = false;
String result = "";
for (char ot : arr) {
if (bool1) {
result += ot + "";
} else {
if (spChar.contains(ot + "")) {
if (!bool1) {
bool1 = true;
} else {
return result;
}
}
}
}
return result;
}
}
Mcode
Code:
package filter;
import java.util.ArrayList;
import java.util.List;
public class WhatFilter {
private String[] defaultWhats = { "switch" };
private List<String> whats = new ArrayList<>();
public String[] getDefaultWhats() {
return defaultWhats;
}
public void setDefaultWhats(String[] defaultWhats) {
this.defaultWhats = defaultWhats;
}
public List<String> getWhats() {
return whats;
}
public void setWhats(String input) {
this.whats = getConjuratis(input, this.defaultWhats);
}
public List<String> getConjuratis(String input, String[] conjurati) {
List<String> result = new ArrayList<>();
for (String strTemp : conjurati) {
if (input.contains(strTemp)) {
result.add(strTemp);
}
}
return result;
}
}
who extends what class
Code:
package filter;
import java.util.ArrayList;
import java.util.List;
public class Who extends WhatFilter {
private String[] defaultNames = { "moti" };
private List<String> who = new ArrayList<>();
public Who(String input) {
super.setWhats(input);
this.who = getConjuratis(input, this.defaultNames);
}
public String[] getDefaultNames() {
return defaultNames;
}
public void setDefaultNames(String[] defaultNames) {
this.defaultNames = defaultNames;
}
public List<String> getWho() {
return who;
}
public void setWho(String input) {
this.who = getConjuratis(input, this.defaultNames);
}
}
hadoshouryuengekimahou ken