Advertisement
dfilipeloja

Exercicio 2 Mooshak

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