Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP Train
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CELERIER Auguste
TP Train
Commits
424451a7
"...src/git@gitlab-df.imt-atlantique.fr:a24miran/wishlist.git" did not exist on "38e99e786d952fda148baff3af45d7a1af7b70e3"
Commit
424451a7
authored
4 months ago
by
CELERIER Auguste
Browse files
Options
Downloads
Patches
Plain Diff
move()
parent
598f9120
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/train/Position.java
+19
-1
19 additions, 1 deletion
src/train/Position.java
with
19 additions
and
1 deletion
src/train/Position.java
+
19
−
1
View file @
424451a7
...
...
@@ -21,7 +21,7 @@ package train;
*/
public
class
Position
implements
Cloneable
{
private
final
Direction
direction
;
private
final
Element
pos
;
private
Element
pos
;
public
Position
(
Element
elt
,
Direction
d
)
{
if
(
elt
==
null
||
d
==
null
)
...
...
@@ -44,6 +44,24 @@ public class Position implements Cloneable {
public
Element
getPos
()
{
return
pos
;
}
public
void
move
(
Railway
railway
)
{
if
(
railway
==
null
)
{
throw
new
NullPointerException
(
"Railway cannot be null."
);
}
try
{
// Get the next element based on the current position and direction
Element
nextElement
=
railway
.
nextElement
(
this
.
pos
,
this
.
direction
);
this
.
pos
=
nextElement
;
}
catch
(
IllegalArgumentException
e
)
{
// If no next element exists, reverse the direction
this
.
direction
.
turn
();
}
}
@Override
public
String
toString
()
{
...
...
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
register
or
sign in
to comment