Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alvaro Ordóñez Romero
/
DAE-aha00026-aor00039
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
04d63cbc
authored
Nov 09, 2023
by
Alvaro Ordóñez Romero
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Modificaciones Usuario.java
parent
022f32c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
16 deletions
src/main/java/com/carpooling/carpoolingaoraha/entidades/Usuario.java
src/main/java/com/carpooling/carpoolingaoraha/entidades/Usuario.java
View file @
04d63cbc
...
...
@@ -10,11 +10,10 @@ import javax.validation.constraints.Pattern;
import
javax.validation.constraints.Size
;
import
java.util.*
;
import
static
com
.
carpooling
.
carpoolingaoraha
.
entidades
.
Rol
.
CONDUCTOR
;
import
static
com
.
carpooling
.
carpoolingaoraha
.
entidades
.
Rol
.
PASAJERO
;
import
static
com
.
carpooling
.
carpoolingaoraha
.
entidades
.
Rol
.*;
enum
Rol
{
CONDUCTOR
,
PASAJERO
CONDUCTOR
,
PASAJERO
,
AMBOS
};
@Entity
@Table
(
name
=
"usuarios"
)
...
...
@@ -71,11 +70,7 @@ public class Usuario {
this
.
claveAcceso
=
claveAcceso
;
this
.
puntuacion
=
new
ArrayList
<>();
this
.
rol
=
rol
;
if
(
rol
==
CONDUCTOR
){
this
.
viajesOfertados
=
new
ArrayList
<>();
}
else
{
this
.
viajesOfertados
=
null
;
}
this
.
sistemaCarPooling
=
new
SistemaCarPooling
();
puntuacionMedia
=
0
;
}
...
...
@@ -165,15 +160,11 @@ public class Usuario {
}
public
void
cambiarRol
(){
if
(
this
.
rol
==
CONDUCTOR
){
rol
=
PASAJERO
;
}
else
{
rol
=
CONDUCTOR
;
}
this
.
rol
=
AMBOS
;
}
public
boolean
ofrecerViaje
(
String
origen
,
String
destino
,
Date
fechaSalida
,
int
nAsientos
,
int
precioAsiento
){
if
(
this
.
rol
==
CONDUCTOR
)
{
if
(
this
.
rol
==
CONDUCTOR
||
this
.
rol
==
AMBOS
)
{
//Crea una reserva
Reserva
reserva
=
new
Reserva
(
this
,
origen
,
destino
,
fechaSalida
,
nAsientos
,
precioAsiento
);
this
.
viajesOfertados
.
add
(
reserva
.
getIdReserva
());
...
...
@@ -183,7 +174,7 @@ public class Usuario {
}
public
boolean
aceptarPasajero
(
int
idReserva
,
String
DNI
,
Rol
rol
){
//Le pasamos el rol del conductor
if
(
rol
==
CONDUCTOR
){
if
(
rol
==
CONDUCTOR
||
rol
==
AMBOS
){
for
(
int
i
=
0
;
i
<
this
.
sistemaCarPooling
.
getReservas
().
size
();
i
++){
if
(
idReserva
==
this
.
sistemaCarPooling
.
getReservas
().
get
(
i
).
getIdReserva
()
&&
this
.
sistemaCarPooling
.
getReservas
().
get
(
i
).
haySitioDisponible
()){
this
.
sistemaCarPooling
.
getReservas
().
get
(
i
).
anadirPasajeros
(
DNI
,
idReserva
);
...
...
@@ -212,7 +203,7 @@ public class Usuario {
for
(
Viaje
viaje
:
todosLosViajes
)
{
if
(
viaje
.
getOrigen
().
equals
(
origen
)
&&
viaje
.
getDestino
().
equals
(
destino
)
&&
viaje
.
getFechaSalida
().
equals
(
fecha
))
{
if
(
getRol
().
equals
(
PASAJERO
))
{
if
(
getRol
().
equals
(
PASAJERO
)
||
getRol
().
equals
(
AMBOS
)
)
{
viajesDisponibles
.
add
(
viaje
);
}
}
...
...
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