Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if((keyboard.next()).equals("create"))
- {
- xValue = keyboard.nextInt();
- yValue = keyboard.nextInt();
- if((keyboard.next().equals("fast")))
- {
- pieceType = "FP";
- if((keyboard.next().equals("flexible")))
- {
- pieceType = "FF";
- }
- }
- if((keyboard.next().equals("flexible")))
- {
- pieceType = "SF";
- if((keyboard.next().equals("fast")))
- {
- pieceType = "FF";
- }
- }
- }
- String NEW_LINE_SIGN = "n";
- if (keyboard.next().contains(NEW_LINE_SIGN){ /* .... */ }
- Scanner kbd = new Scanner(System.in);
- kbd.useDelimiter(System.getProperty("line.separator"));
- //you could create a rule automatically with some kind of a rules engine
- if(kbd.hasNext("create(\s+)(\d+)(\s+)(\d+)(\s+)(fast|flexible)(\s+)(fast|flexible)")) {
- MatchResult res = kbd.match();
- for(int i = 0; i <= res.groupCount(); ++i) {
- System.out.println(res.group(i));
- //handleRules(res.group(i), i);
- }
- }
- kbd.close();
Add Comment
Please, Sign In to add comment