Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. package Model.Statements;
  2.  
  3. import Model.Expressions.Exp;
  4. import Model.Expressions.NotExp;
  5. import Model.PrgState;
  6. import MyExceptions.MyControllerException;
  7.  
  8. public class RepeatStmt implements IStmt {
  9. private IStmt stmt;
  10. private Exp exp;
  11.  
  12. public RepeatStmt(IStmt stmt, Exp exp)
  13. {
  14. this.stmt = stmt;
  15. this.exp = exp;
  16. }
  17.  
  18. @Override
  19. public PrgState execute(PrgState state) throws MyControllerException {
  20. IStmt act = new CompStmt(stmt, new WhileStmt(new NotExp(this.exp), stmt));
  21. state.getStk().push(act);
  22.  
  23. return null;
  24. }
  25.  
  26. @Override
  27. public String toString() {
  28. return "repeat(" + stmt.toString() + ") until" + exp.toString();
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement