Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ejercicio_4;
- public class Excursion {
- private String nombre;
- private Date fechaInicio;
- private int duracion;
- private int costo;
- public Excursion() {
- setNombre(nombre);
- setFechaInicio(fechaInicio);
- setDuracion(duracion);
- setCosto(costo);
- }
- //Setters
- public void setNombre(String nombre) {
- if(nombre.length() > 0) {
- this.nombre = nombre;
- }
- else {
- throw new RuntimeException("Nombre de Excursion erroneo");
- }
- }
- public void setFechaInicio(Date fechaInicio) {
- this.fechaInicio = fechaInicio;
- }
- public void setDuracion(int duracion) {
- if(duracion > 0) {
- this.duracion = duracion;
- }
- else {
- throw new RuntimeException("Duracion de Excursion erronea");
- }
- }
- public void setCosto(int costo) {
- int valor = 500; //el monto de valor va a depender de lo establecido por la empresa
- if(costo >= valor) {
- this.costo = costo;
- }
- else {
- throw new RuntimeException("Costo invalido");
- }
- }
- //Getterws
- public String getNombre() {...
- public Date getFechaInicio() {...
- public int getDuracion() {...
- public int getCosto() {...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement