Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Application {
- public static void main(String[] args) {
- State e0 = new State(new String("e0"));
- State h1 = new State(new String("h1"));
- State h2 = new State(new String("h2"));
- State h = new State(new String("h"));
- State m = new State(new String("m"));
- Label v0 = new Label(new String(":"));
- Label v1 = new Label(new String(";"));
- Label v2 = new Label(new String("-"));
- Label v3 = new Label(new String("="));
- Label v4 = new Label(new String(")"));
- Label v5 = new Label(new String("("));
- e0.addTransition(v0, h1);
- e0.addTransition(v1, h1);
- h1.addTransition(v2, h);
- h1.addTransition(v3, h);
- h2.addTransition(v2, h);
- h.addTransition(v4, m);
- h.addTransition(v5, m);
- ArrayList<State> states = new ArrayList<>();
- states.add(e0);
- states.add(h1);
- states.add(h2);
- states.add(h);
- states.add(m);
- ArrayList<State> finalStates = new ArrayList<>();
- finalStates.add(m);
- NierAuxTomates auxTomates = new NierAuxTomates(e0, finalStates, states);
- String[] resultat;
- String typed;
- Scanner reader = new Scanner(System.in);
- Label[] values;// = new Label[]{v0,v2,v42,v0,v0};
- values = new Label[5];
- while (true) {
- System.out.println("Please type an hour, or if you want to leave, type \"leave\" : ");
- typed = reader.next();
- if (typed.contains("leave")) System.exit(0);
- if (typed.length() == 3) {
- for (int i = 0; i <= 2; i++) {
- switch (String.valueOf(typed.charAt(i))) {
- case ":":
- values[i] = v0;
- break;
- case ";":
- values[i] = v1;
- break;
- case "-":
- values[i] = v2;
- break;
- case "=":
- values[i] = v3;
- break;
- case ")":
- values[i] = v4;
- break;
- case "(":
- values[i] = v5;
- break;
- default:
- values[0] = null;
- break;
- }
- }
- if (values[0] != null) {
- resultat = auxTomates.execute(values);
- if (resultat[0] != null) {
- System.out.println("Possible combination, here is the result : " + resultat[0] + resultat[1] + resultat[2]);
- } else {
- System.out.println("Impossible combination");
- }
- }
- else{
- System.out.println("Impossible combination");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement