Ir para conteúdo
Fórum Script Brasil

Jo83

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que Jo83 postou

  1. Oi pessoal, Quero verificar se a posicao 0 do arrayList Tasks está em qualquer posicao do arrayList Dependences. Se posicao 0 estiver, tento verificar se a posicao B está. E assim vai um por um. Vou armazendo no arrayList Qe as tasks que não estao no arrayList dependences. Meu codigo esta retornando vazio, mas ele deveria retornar o elemento 1, 2 e 12. import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.Scanner; public class ImplQueue { ArrayList<String> qe= new ArrayList<String>(); //queue tasks ArrayList<String> tasks = new ArrayList<String>(); ArrayList<String> dependences = new ArrayList<String>(); ArrayList<String> cp = new ArrayList<String>(); ArrayList<String> effort = new ArrayList<String>(); int index = 0; // unlock index/task public void createQe() throws Exception{ Scanner s = new Scanner(new File("filedata.txt")); while (s.hasNext()) { tasks.add(s.nextLine()); dependences.add(s.nextLine()); cp.add(s.nextLine()); effort.add(s.nextLine()); } s.close(); System.out.println("Queue tasks ID: "+ tasks.toString()); System.out.println("Queue dependences: "+ dependences.toString()); System.out.println("Queue CP allocation: "+ cp.toString()); System.out.println("Queue effort hour: "+ effort.toString()); } //find unlock task in the queue public void findUnlock(){ while (!(qe.isEmpty())){ for (int i=0; i<= dependences.size(); i++){ if (dependences.get(i).equals(tasks.get(0))){ qe.add(tasks.get(0)); tasks.remove(0); } else { System.out.println("False"); return; } } } System.out.println("Queue unlock tasks: "+ qe.toString()); System.out.println("Remain tasks: "+ tasks.toString()); } } Meu output: Queue tasks ID: [1 2 3 4 5 6 7 8 9 10 11 12 ] Queue dependences: [null 3 4 5 5 5 6 7 8 9 10 null] Queue CP allocation: [cp1 cp2 cp1 cp2 cp1 cp2 cp1 cp2 cp1 cp2 cp1 cp2] Queue effort hour: [4 7 10 10 5 27 4 8 9 10 11 10 22 ] Queue unlock tasks: [] Remain tasks: [1 2 3 4 5 6 7 8 9 10 11 12 ]
×
×
  • Criar Novo...