String regularExp = "\\d{1,4}";
CharSequence charSeq = param1;
if (param1.equals("")){
inputCount = 2;
AndGate ag = new AndGate(inputCount);
Main.controller.getDisplayView().addComponentView(new AndGateView(0, 0, ag));
System.out.println(ag.getName() + " CREATED with " + inputCount + " inports.");
output += ag.getName() + " CREATED with " + inputCount + " inports.\n";
} else if ((param2.equals(""))) {
if (Pattern.matches(regularExp, param1)){
inputCount = Integer.parseInt(param1);
AndGate ag = new AndGate(inputCount);
Main.controller.getDisplayView().addComponentView(new AndGateView(100, 0, ag));
System.out.println(ag.getName() + " CREATED with " + inputCount + " inports.");
output += ag.getName() + " CREATED with " + inputCount + " inports.\n";
//Prototype.PrintStateAfterUpdate(ag);
} else if (Pattern.matches("\\(\\d{1,4}\\,\\d{1,4}\\)", param1)){
inputCount = 2;
AndGate ag = new AndGate(inputCount);
Main.controller.getDisplayView().addComponentView(new AndGateView(getPosX(param1),getPosY(param1), ag));
System.out.println(ag.getName() + " CREATED with " + inputCount + " inports.");
output += ag.getName() + " CREATED with " + inputCount + " inports.\n";
//Prototype.PrintStateAfterUpdate(ag);
}
} else if (Pattern.matches("\\(\\d{1,4}\\,\\d{1,4}\\)", param2)) {
if (Pattern.matches(regularExp, param1)) {
inputCount = Integer.parseInt(param1);
if (inputCount >= 2) {
AndGate ag = new AndGate(inputCount);
//Main.controller.getDisplayView().addComponentView(new AndGateView(100, 100, ag));
//AndGateView felülethez adása
Main.controller.getDisplayView().addComponentView(new AndGateView(getPosX(param2), getPosY(param2), ag));
System.out.println(ag.getName() + " CREATED with " + inputCount + " inports.");
output += ag.getName() + " CREATED with " + inputCount + " inports.\n";
//Prototype.PrintStateAfterUpdate(ag);
} else {
output += "A gate needs at least 2 inports\n";
}
}