All pastes #397946 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-16 20:57 UTC
rendered paste body
package br.cesupa.exercicios.vivi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;

public class MesesDiaSemana {
	public enum Mes { Jan, Fev, Mar, Abr, Mai, Jun, Jul, Ago, Set, Out, Nov, Dez};
	public enum DiasSemana { Seg, Ter, Qua, Qui, Sex, Sab, Dom };

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayList<LinkedList<DiasSemana>> combinacoes = new ArrayList<LinkedList<DiasSemana>>();
		
		for (int i = 0; i < 12; i++)
			combinacoes.add(new LinkedList<DiasSemana>(Arrays.asList(DiasSemana.values())));
		
		boolean termino = false;
		while (! termino) {
			String[] txtValores = new String[combinacoes.size()];
			
			int i = 0;
			for (Mes mes : Mes.values())
				txtValores[i++] = mes + "->" + combinacoes.get(mes.ordinal()).peek();
			
			String valores = Arrays.toString(txtValores);
			
			System.out.println(valores);
			
			for (int j = 0; j < 12; j++) {
				LinkedList<DiasSemana> combinacao = combinacoes.get(j);
				
				if (null == combinacao.peek()) {
					if (11 == j) {
						termino = true;
						break;
					}
					combinacoes.set(j, new LinkedList<DiasSemana>(Arrays.asList(DiasSemana.values())));
				} else {
					combinacao.poll();

					break;
				}
			}
		}
	}
}