Advertisement
fmbalvarez

Martes 28 - Curso

Oct 28th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1.  
  2. public class Alumno {
  3.  
  4.     private String nombre;
  5.     private String apellido;
  6.     private double nota;
  7.    
  8.     public void setNombre (String nombre){
  9.        
  10.         this.nombre = nombre;
  11.     }
  12.  
  13.     public String getNombre (){
  14.        
  15.         return (nombre);
  16.     }
  17.    
  18.     public void setApellido (String apellido){
  19.        
  20.         this.apellido = apellido;
  21.     }
  22.  
  23.     public String getApellido (){
  24.        
  25.         return (apellido);
  26.     }
  27.    
  28.     public void setNota (int nota){
  29.        
  30.         this.nota = nota;
  31.     }
  32.  
  33.     public double getNota (){
  34.        
  35.         return (nota);
  36.     }
  37.    
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44. public class Curso {
  45.    
  46.    
  47.     private Alumno[] alumnos;
  48.    
  49.     public Curso (int cantidadDeAlumnos){
  50.        
  51.         alumnos = new Alumno [cantidadDeAlumnos];
  52.        
  53.         for (int i = 0; i < alumnos.length; i++){
  54.            
  55.             alumnos [i] =  new Alumno ();
  56.         }
  57.     }
  58.    
  59.     public double calcularPromedio(){
  60.        
  61.         double sumatoriaDeNotas = 0.0;
  62.        
  63.         for (int i = 0; i < alumnos.length; i++){
  64.            
  65.             sumatoriaDeNotas = sumatoriaDeNotas + alumnos[i].getNota();
  66.         }
  67.        
  68.         return sumatoriaDeNotas;
  69.     }
  70.  
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. import org.junit.Test;
  79. import org.junit.Before;
  80. import org.junit.Assert;
  81.  
  82.  
  83. public class PruebaCurso {
  84.  
  85.     @Test
  86.    
  87.     public void probarCalcularPromedio(){
  88.        
  89.         Curso algoritmos = new Curso(2);
  90.         alumnos[0].setNota(10);
  91.        
  92.        
  93.        
  94.        
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement