Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Antonio Rueda
/
reserva-hoteles
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e741188a
authored
Sep 25, 2024
by
Antonio Rueda
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Primera versión del modelo, con implementaciones parciales.
parent
d7d369a4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
242 additions
and
0 deletions
pom.xml
src/main/java/es/ujaen/dae/reservahoteles/app/ReservaHoteles.java
src/main/java/es/ujaen/dae/reservahoteles/entidades/Cliente.java
src/main/java/es/ujaen/dae/reservahoteles/entidades/Hotel.java
src/main/java/es/ujaen/dae/reservahoteles/entidades/Reserva.java
src/main/java/es/ujaen/dae/reservahoteles/excepciones/ClienteYaRegistrado.java
src/main/java/es/ujaen/dae/reservahoteles/servicios/ServicioReservas.java
pom.xml
0 → 100644
View file @
e741188a
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
es.ujaen.dae
</groupId>
<artifactId>
ReservaHoteles
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<java.version>
21
</java.version>
</properties>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
3.3.4
</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/main/java/es/ujaen/dae/reservahoteles/app/ReservaHoteles.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
app
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
/**
*
* @author ajrueda
*/
@SpringBootApplication
(
scanBasePackages
=
"es.ujaen.dae.reservahoteles.servicios"
)
public
class
ReservaHoteles
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ReservaHoteles
.
class
);
}
}
src/main/java/es/ujaen/dae/reservahoteles/entidades/Cliente.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
entidades
;
/**
*
* @author ajrueda
*/
public
class
Cliente
{
String
nombre
;
String
direccion
;
String
tlf
;
// Clave
String
email
;
String
clave
;
public
Cliente
(
String
nombre
,
String
direccion
,
String
tlf
,
String
email
,
String
clave
)
{
this
.
nombre
=
nombre
;
this
.
direccion
=
direccion
;
this
.
tlf
=
tlf
;
this
.
email
=
email
;
this
.
clave
=
clave
;
}
public
String
email
()
{
return
email
;
}
public
String
clave
()
{
return
clave
;
}
}
src/main/java/es/ujaen/dae/reservahoteles/entidades/Hotel.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
entidades
;
import
java.time.LocalDate
;
import
java.util.Collections
;
import
java.util.Map
;
/**
*
* @author ajrueda
*/
public
class
Hotel
{
int
id
;
String
nombre
;
// Dirección
String
localidad
;
String
provincia
;
int
cp
;
// Disponibilidad habitaciones
int
numHabSimple
;
int
numHabDoble
;
// Precio habitaciones
int
precioHabSimple
;
int
precioHabDoble
;
Map
<
LocalDate
,
Reserva
>
reservas
;
public
Hotel
(
int
id
,
String
nombre
,
String
localidad
,
String
provincia
,
int
cp
,
int
numHabSimple
,
int
numHabDoble
,
int
precioHabSimple
,
int
precioHabDoble
)
{
this
.
id
=
id
;
this
.
nombre
=
nombre
;
this
.
localidad
=
localidad
;
this
.
provincia
=
provincia
;
this
.
cp
=
cp
;
this
.
numHabSimple
=
numHabSimple
;
this
.
numHabDoble
=
numHabDoble
;
this
.
precioHabSimple
=
precioHabSimple
;
this
.
precioHabDoble
=
precioHabDoble
;
reservas
=
Collections
.
emptySortedMap
();
}
public
int
id
()
{
return
id
;
}
}
src/main/java/es/ujaen/dae/reservahoteles/entidades/Reserva.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
entidades
;
import
java.time.LocalDate
;
/**
*
* @author ajrueda
*/
public
class
Reserva
{
// clave
int
num
;
// Fechas de inicio y fin de reserva
LocalDate
fechaInicio
;
LocalDate
fechaFin
;
// Número de habitaciones reservadas;
int
numHabSimple
;
int
numHabDoble
;
Cliente
cliente
;
public
Reserva
(
int
num
,
Cliente
cliente
,
LocalDate
fechaInicio
,
LocalDate
fechaFin
,
int
numHabSimple
,
int
numHabDoble
)
{
this
.
num
=
num
;
this
.
cliente
=
cliente
;
this
.
fechaInicio
=
fechaInicio
;
this
.
fechaFin
=
fechaFin
;
this
.
numHabSimple
=
numHabSimple
;
this
.
numHabDoble
=
numHabDoble
;
}
}
src/main/java/es/ujaen/dae/reservahoteles/excepciones/ClienteYaRegistrado.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
excepciones
;
/**
*
* @author ajrueda
*/
public
class
ClienteYaRegistrado
extends
RuntimeException
{
public
ClienteYaRegistrado
()
{
}
}
src/main/java/es/ujaen/dae/reservahoteles/servicios/ServicioReservas.java
0 → 100644
View file @
e741188a
package
es
.
ujaen
.
dae
.
reservahoteles
.
servicios
;
import
es.ujaen.dae.reservahoteles.entidades.Cliente
;
import
es.ujaen.dae.reservahoteles.entidades.Hotel
;
import
es.ujaen.dae.reservahoteles.entidades.Reserva
;
import
es.ujaen.dae.reservahoteles.excepciones.ClienteYaRegistrado
;
import
java.time.LocalDate
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
/**
*
* @author ajrueda
*/
public
class
ServicioReservas
{
Map
<
Integer
,
Hotel
>
hoteles
;
Map
<
String
,
Cliente
>
clientes
;
public
ServicioReservas
()
{
hoteles
=
Collections
.
emptyMap
();
clientes
=
Collections
.
emptyMap
();
}
public
void
nuevoHotel
(
Hotel
hotel
)
{
hoteles
.
put
(
hotel
.
id
(),
hotel
);
}
public
void
nuevoCliente
(
Cliente
cliente
)
{
if
(
clientes
.
containsKey
(
cliente
.
email
()))
throw
new
ClienteYaRegistrado
();
clientes
.
put
(
cliente
.
email
(),
cliente
);
}
public
Optional
<
Cliente
>
login
(
String
email
,
String
clave
)
{
return
Optional
.
ofNullable
(
clientes
.
get
(
email
))
.
filter
(
cliente
->
cliente
.
clave
().
equals
(
clave
));
}
public
List
<
Hotel
>
buscarPorLocalidad
(
String
localidad
,
LocalDate
fechaInicio
,
LocalDate
fechaFin
,
int
numHabSimple
,
int
numHabDoble
)
{
// Por implementar
throw
new
UnsupportedOperationException
();
}
public
Reserva
reserva
(
Cliente
cliente
,
Hotel
hotel
,
LocalDate
fechaInicio
,
LocalDate
fechaFin
,
int
numHabSimple
,
int
numHabDoble
)
{
// Por implementar
throw
new
UnsupportedOperationException
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment