/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package core; /** * * @author LAB.INFORMATICA12 */ public class Command { //Atributos private String commandText; private final Stack stk; //Agregación de Stack //Construct public Command() { this.commandText=""; this.stk=new Stack(); } //getters and Setters public String getCommandText() { return commandText; } public void setCommandText(String commandText) { this.commandText = commandText; } //Métodos public String presentarStack(){ String resp=""; for(int i=0; i<this.stk.getArreglo().size();i++){ resp+=this.stk.getArreglo().get(i)+'\n'; } return resp; } public void saludar(String name){ this.stk.addItem("hola "+ name); } public void commandExe(String command, String args){ String resp="No command found!"; this.commandText=command; switch (this.commandText) { case "saludar": this.saludar(args); break; case "sumarTodo": resp=this.stk.sumar(); this.stk.getArreglo().add(resp); break; default: this.stk.getArreglo().add(resp); break; } } } |