Guest User

Untitled

a guest
Jan 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. if((keyboard.next()).equals("create"))
  2. {
  3. xValue = keyboard.nextInt();
  4. yValue = keyboard.nextInt();
  5.  
  6. if((keyboard.next().equals("fast")))
  7. {
  8. pieceType = "FP";
  9. if((keyboard.next().equals("flexible")))
  10. {
  11. pieceType = "FF";
  12. }
  13. }
  14.  
  15.  
  16. if((keyboard.next().equals("flexible")))
  17. {
  18. pieceType = "SF";
  19. if((keyboard.next().equals("fast")))
  20. {
  21. pieceType = "FF";
  22. }
  23. }
  24. }
  25.  
  26. String NEW_LINE_SIGN = "n";
  27. if (keyboard.next().contains(NEW_LINE_SIGN){ /* .... */ }
  28.  
  29. Scanner kbd = new Scanner(System.in);
  30. kbd.useDelimiter(System.getProperty("line.separator"));
  31. //you could create a rule automatically with some kind of a rules engine
  32. if(kbd.hasNext("create(\s+)(\d+)(\s+)(\d+)(\s+)(fast|flexible)(\s+)(fast|flexible)")) {
  33. MatchResult res = kbd.match();
  34. for(int i = 0; i <= res.groupCount(); ++i) {
  35. System.out.println(res.group(i));
  36. //handleRules(res.group(i), i);
  37. }
  38. }
  39. kbd.close();
Add Comment
Please, Sign In to add comment