Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void readInput() {
- // Leggo la linea
- String line = s.nextLine();
- // splitto la prima volta per il valore
- String[] sub = line.split(" ");
- // splitto la seconda volta per prendere L'intero
- String[] sub1 = sub[0].split("");
- boolean value;
- String number = "";
- for (int i = 1; i < sub[0].length() - 1; i++) {
- number += sub1[i];
- }
- Integer id = Integer.parseInt(number);
- if (sub[1].equals("True"))
- value = true;
- else
- value = false;
- // inizializzo la radice
- boolWithId root = new boolWithId(value, id);
- Node<boolWithId> N1 = new Node<boolWithId>(root);
- tree.setRootElement(N1);
- nodes.add(N1);
- // fin quando ha nodi in input leggo.
- while (s.hasNextLine()) {
- line = s.nextLine();
- // splitto la prima volta per le singole sottostringhe
- sub = line.split(" ");
- // splitto la seconda volta per prendere L'intero
- sub1 = sub[0].split("");
- String number1 = "";
- for (int i = 1; i < sub[0].length() - 1; i++) {
- number1 += sub1[i];
- }
- id = Integer.parseInt(number1);
- if (sub[1].equals("True"))
- value = true;
- else
- value = false;
- boolWithId n = new boolWithId(value, id);
- Node<boolWithId> N = new Node<boolWithId>(n);
- Integer idToAssign = Integer.parseInt(sub[3]);
- nodes.add(N);
- for (Node<boolWithId> b : nodes) {
- if (b.getData().getId() == idToAssign) {
- if (sub[4].equals("<"))
- b.insertChildAt(0, N);
- else if (sub[4].equals(">")) {
- if (b.getNumberOfChildren() == 0) {
- b.insertChildAt(0, N);
- } else
- b.insertChildAt(1, N);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement