Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Entrega_javcalv_victorm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
javcalv
Entrega_javcalv_victorm
Commits
e4ebaaaf
Commit
e4ebaaaf
authored
11 months ago
by
Javier Calvo
Browse files
Options
Downloads
Patches
Plain Diff
Añadir y eliminar muelle
parent
1e1dce36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/es/markse/Puerto.java
+21
-11
21 additions, 11 deletions
src/es/markse/Puerto.java
with
21 additions
and
11 deletions
src/es/markse/Puerto.java
+
21
−
11
View file @
e4ebaaaf
...
@@ -22,30 +22,40 @@ public class Puerto {
...
@@ -22,30 +22,40 @@ public class Puerto {
}
}
/**
/**
* 1.1.1.
* 1.1.1. Metodo que agrega un nuevo muelle al puerto. Se comprueba que ese muelle no se encuentre ya agregado.
* Funcion que agrega un nuevo muelle al puerto
* Comprueba que ese muelle no se encuentre ya agregado
* @param m objeto tipo Muelle
* @param m objeto tipo Muelle
*/
*/
public
void
anyadirMuelle
(
Muelle
m
)
{
public
void
anyadirMuelle
(
Muelle
m
)
{
//Comprobar que el muelle no este ya dentro
if
(!
this
.
comprobarMuelleEnPuerto
(
m
))
{
if
(
this
.
comprobarMuelleEnPuerto
(
m
))
{
this
.
muelles
.
add
(
m
);
this
.
muelles
.
add
(
m
);
}
}
else
{
throw
new
IllegalArgumentException
(
"Ese muelle ya esta dentro"
);
}
}
/**
* 1.1.2 Método que elimina un muelle del puerto.
* @param id Identificador del muelle que se elimina
* @return
*/
public
boolean
eliminarMuelle
(
String
id
)
{
return
this
.
muelles
.
removeIf
(
muelle
->
muelle
.
getIdentificador
().
equals
(
id
));
}
}
/**
/**
* Funcion para comprobar si un muelle esta en ese puerto o no, para agregarle o eliminarle
* Funcion para comprobar si un muelle esta en ese puerto o no, para agregarle o eliminarle
* Metodo empleado por anyadirMuelle() y eliminarMuelle()
* @param m obtejo Muelle
* @param m obtejo Muelle
* @return true/false
* @return true/false
*/
*/
public
boolean
comprobarMuelleEnPuerto
(
Muelle
m
)
{
public
boolean
comprobarMuelleEnPuerto
(
Muelle
m
)
{
//Mediante el id, comprobamos si esta ese muelle o no y devuelve true/false
String
id
=
m
.
getIdentificador
();
for
(
Muelle
muelle
:
this
.
muelles
)
{
if
(
id
.
equals
(
muelle
.
getIdentificador
()))
{
return
true
;
}
}
}
return
false
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment