Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WarGames
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tomas Beranek
WarGames
Commits
a72342c1
Commit
a72342c1
authored
3 years ago
by
Tomas Beranek
Browse files
Options
Downloads
Patches
Plain Diff
docs: docs written for new method
parent
4a613ada
No related branches found
No related tags found
2 merge requests
!5
Merging simulation branch with main branch
,
!4
Merging Main branch with Simulation branch
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/ntnu/idatt2001/Wargames/battlesimulation/battle/ArmyFiles.java
+3
-7
3 additions, 7 deletions
...idatt2001/Wargames/battlesimulation/battle/ArmyFiles.java
with
3 additions
and
7 deletions
src/main/java/edu/ntnu/idatt2001/Wargames/battlesimulation/battle/ArmyFiles.java
+
3
−
7
View file @
a72342c1
package
edu.ntnu.idatt2001.Wargames.battlesimulation.battle
;
package
edu.ntnu.idatt2001.Wargames.battlesimulation.battle
;
import
edu.ntnu.idatt2001.Wargames.battlesimulation.controllers.SimulationSingleton
;
import
edu.ntnu.idatt2001.Wargames.battlesimulation.controllers.SimulationSingleton
;
import
edu.ntnu.idatt2001.Wargames.battlesimulation.maintnance.PopupBoxes
;
import
edu.ntnu.idatt2001.Wargames.battlesimulation.specificunits.Unit
;
import
edu.ntnu.idatt2001.Wargames.battlesimulation.specificunits.Unit
;
import
javafx.stage.FileChooser
;
import
javafx.stage.FileChooser
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -13,7 +11,6 @@ import java.nio.file.Files;
...
@@ -13,7 +11,6 @@ import java.nio.file.Files;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -120,6 +117,7 @@ public class ArmyFiles {
...
@@ -120,6 +117,7 @@ public class ArmyFiles {
/**
/**
* method used for checking for illegal characters which can corrupt a file
* method used for checking for illegal characters which can corrupt a file
*
* @param lines a line from the file
* @param lines a line from the file
* @return true if the line doesn't consist of illegal characters
* @return true if the line doesn't consist of illegal characters
* @throws IllegalArgumentException if an illegal character is found
* @throws IllegalArgumentException if an illegal character is found
...
@@ -142,9 +140,8 @@ public class ArmyFiles {
...
@@ -142,9 +140,8 @@ public class ArmyFiles {
* checks if string consist of numbers
* checks if string consist of numbers
*
*
* @param lines string to be checked
* @param lines string to be checked
* @return true or false depending on outcome
*/
*/
public
boolean
checkInputForIntegers
(
String
lines
)
{
public
void
checkInputForIntegers
(
String
lines
)
{
String
chekIfInt
=
"[0-9]+"
;
String
chekIfInt
=
"[0-9]+"
;
Pattern
pt
=
Pattern
.
compile
(
chekIfInt
);
Pattern
pt
=
Pattern
.
compile
(
chekIfInt
);
Matcher
mt
=
pt
.
matcher
(
lines
);
Matcher
mt
=
pt
.
matcher
(
lines
);
...
@@ -152,6 +149,5 @@ public class ArmyFiles {
...
@@ -152,6 +149,5 @@ public class ArmyFiles {
if
(!
mt
.
matches
())
{
if
(!
mt
.
matches
())
{
throw
new
IllegalArgumentException
(
"Health value in file is a String, not a Integer"
);
throw
new
IllegalArgumentException
(
"Health value in file is a String, not a Integer"
);
}
}
return
true
;
}
}
}
}
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