-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHabitacion.java
61 lines (50 loc) · 1.45 KB
/
Habitacion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
public class Habitacion {
private int numero;
private double costoPorNoche;
private boolean ocupada;
private Persona cliente;
// Constructor
public Habitacion(int numero, double costoPorNoche) {
this.numero = numero;
this.costoPorNoche = costoPorNoche;
this.ocupada = false;
}
// Getters y setters
public int getNumero() {
return numero;
}
public void setNumero(int numero) {
this.numero = numero;
}
public double getCostoPorNoche() {
return costoPorNoche;
}
public void setCostoPorNoche(double costoPorNoche) {
this.costoPorNoche = costoPorNoche;
}
public boolean isOcupada() {
return ocupada;
}
public void setOcupada(boolean ocupada) {
this.ocupada = ocupada;
}
public Persona getCliente() {
return cliente;
}
public void setCliente(Persona cliente) {
this.cliente = cliente;
}
// reservar habitación
public void reservar(Persona cliente) {
if (!ocupada) {
this.cliente = cliente;
ocupada = true;
System.out.println("Habitación " + numero + " reservada para: " + cliente.getNombre());
} else {
System.out.println("La habitación " + numero + " ya está ocupada.");
}
}
// liberar habitación
public void liberar() {
if (ocupada) {
System.out.println("Habitación " +