Advertisement
Guest User

Ejercicio 4 Entregable parte 2

a guest
Apr 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. package Ejercicio_4;
  2.  
  3. public class Excursion {
  4.     private String nombre;
  5.     private Date fechaInicio;
  6.     private int duracion;
  7.     private int costo;
  8.  
  9.     public Excursion() {
  10.         setNombre(nombre);
  11.         setFechaInicio(fechaInicio);
  12.         setDuracion(duracion);
  13.         setCosto(costo);
  14.        
  15.     }
  16.    
  17.    
  18.     //Setters
  19.     public void setNombre(String nombre) {
  20.         if(nombre.length() > 0) {
  21.             this.nombre = nombre;
  22.         }
  23.         else {
  24.             throw new RuntimeException("Nombre de Excursion erroneo");
  25.         }
  26.        
  27.     }
  28.     public void setFechaInicio(Date fechaInicio) {
  29.         this.fechaInicio = fechaInicio;
  30.     }
  31.     public void setDuracion(int duracion) {
  32.         if(duracion > 0) {
  33.             this.duracion = duracion;
  34.         }
  35.         else {
  36.             throw new RuntimeException("Duracion de Excursion erronea");
  37.         }
  38.     }
  39.    
  40.     public void setCosto(int costo) {
  41.         int valor = 500; //el monto de valor va a depender de lo establecido por la empresa
  42.         if(costo >= valor) {
  43.             this.costo = costo;
  44.         }
  45.         else {
  46.             throw new RuntimeException("Costo invalido");
  47.         }
  48.     }
  49.    
  50.     //Getterws
  51.     public String getNombre() {...
  52.  
  53.     public Date getFechaInicio() {...
  54.  
  55.     public int getDuracion() {...
  56.  
  57.     public int getCosto() {...
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement