Advertisement
dfilipeloja

Exercicio 1 Mooshak

Apr 12th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Mooshak {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         Atleta atleta = new Atleta(sc.next(), new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()});
  9.        
  10.         atleta.ordenar();
  11.         atleta.imprime();
  12.     }
  13. }
  14.  
  15. class Atleta {
  16.    
  17.     private String nome;
  18.     private int[] tempos = new int[5];
  19.  
  20.    
  21.     public Atleta(String nome, int[] tempos) {
  22.         this.nome = nome;
  23.        
  24.         for (int i = 0; i < tempos.length; i++) {
  25.             this.tempos[i] = tempos[i];
  26.         }
  27.     }
  28.    
  29.     public String getNome() {
  30.         return nome;
  31.     }
  32.    
  33.     public void ordenar() {
  34.         Arrays.sort(tempos);
  35.     }
  36.    
  37.     public void imprime() {
  38.         System.out.print(getNome());
  39.         for (int temp : tempos) {
  40.             System.out.print(" " + temp);
  41.         }
  42.         System.out.println();
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement