Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package runners2016;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Scanner;
- public class utilitarios {
- public static void pausa() {
- Scanner in = new Scanner(System.in);
- System.out.println("\n\nPara continuar prima ENTER");
- in.nextLine();
- }
- public static String dataAtual() {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date d = new Date();
- String data = dateFormat.format(d);
- return data;
- }
- @SuppressWarnings("ManualArrayToCollectionCopy")
- public static void ordenarAlfabeticamente(String[][] socios, int[][] tempos, int nSocios, int N_CAMPOS_INFO, int N_PROVAS) {
- String tmpS;
- int tmpI;
- for (int i = 0; i < nSocios - 1; i++) {
- for (int j = i; j < nSocios; j++) {
- if (socios[i][1].compareTo(socios[j][1]) > 0) {
- for (int k = 0; k < N_CAMPOS_INFO; k++) {
- tmpS = socios[i][k];
- socios[i][k] = socios[j][k];
- socios[j][k] = tmpS;
- }
- for (int x = 0; x < N_PROVAS; x++) {
- tmpI = tempos[i][x];
- tempos[i][x] = tempos[j][x];
- tempos[j][x] = tmpI;
- }
- }
- }
- }
- }
- public static int calcularIdade(String[][] socios, int i) {
- String[] dataHoje = dataAtual().trim().split("/");
- String[] dataNasc = socios[i][2].trim().split("/");
- int AnoNas = Integer.parseInt(dataNasc[2]);
- int AnoAct = Integer.parseInt(dataHoje[2]);
- int idade = AnoAct - AnoNas;
- if (dataHoje[1].compareTo(dataNasc[1]) < 0) {
- idade--;
- }
- if (dataHoje[1].equals(dataNasc[1])) {
- if (dataHoje[0].compareTo(dataNasc[0]) < 0) {
- idade--;
- }
- }
- return idade;
- }
- public static String primeiroUltimoNome(String[][] socios, int nSocios, int pos) {
- String[] temp = socios[pos][1].split(" ");
- String nome = temp[0] + " " + temp[temp.length - 1];
- return nome;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement