package ex.app.edit;
/**
* This command adds a new number to the list of numbers kept by the applcation.
**/
import ex.core.IntegerManager;
import pt.tecnico.po.ui.Command;
import pt.tecnico.po.ui.DialogException;
import pt.tecnico.po.ui.Input;
public class AddNumber extends Command<IntegerManager> {
/** Number to read. */
private Input<Integer> _number;
//Constructor
public AddNumber(IntegerManager ent) {
super("Adicionar Número", ent);
_number = _form.addIntegerInput("Introduza um número: ");
}
protected void execute() { // executed when this option is selected
_form.parse();
if (_receiver.addNumber(_number.value()))
_display.addLine("Número adicionado: " + _number.value());
else
_display.addLine("Número não adicionado");
_display.display();
}
}