Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
project
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC2
oop
project
Commits
94326f68
Commit
94326f68
authored
1 year ago
by
iliya
Browse files
Options
Downloads
Patches
Plain Diff
feat: asking user if he wants to restore a game
parent
7f92a908
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/main/java/hepia/App.java
+50
-19
50 additions, 19 deletions
src/main/java/hepia/App.java
with
50 additions
and
19 deletions
src/main/java/hepia/App.java
+
50
−
19
View file @
94326f68
package
hepia
;
package
hepia
;
import
java.io.IOException
;
import
java.util.Scanner
;
import
java.util.Scanner
;
/**
/**
* App
* App
*/
*/
public
class
App
{
public
class
App
{
private
static
final
Scanner
scanner
=
new
Scanner
(
System
.
in
);
public
static
boolean
askUserToLoadGame
()
{
String
input
;
boolean
inputCorrect
=
false
;
do
{
System
.
out
.
println
();
System
.
out
.
println
(
"Would you like to load an existing game ? [y/n] "
);
input
=
scanner
.
next
();
switch
(
input
)
{
case
"y"
:
return
true
;
case
"n"
:
return
false
;
default
:
break
;
}
}
while
(!
inputCorrect
);
public
static
void
main
(
String
[]
args
)
{
return
false
;
Scanner
scanner
=
new
java
.
util
.
Scanner
(
System
.
in
);
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
if
(
askUserToLoadGame
())
{
System
.
out
.
print
(
"Please specify the path to the `.ser` file: "
);
String
filePath
=
scanner
.
next
();
try
{
GameManager
.
restoreGame
(
filePath
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Game couldn't be restored"
);
System
.
exit
(
1
);
}
}
else
{
System
.
out
.
print
(
"How many decks of cards would like to create: "
);
System
.
out
.
print
(
"How many decks of cards would like to create: "
);
int
nbDecks
=
scanner
.
nextInt
();
int
nbDecks
=
scanner
.
nextInt
();
System
.
out
.
print
(
"Please specify the amount of human players: "
);
System
.
out
.
print
(
"Please specify the amount of human players: "
);
...
@@ -24,7 +56,6 @@ public class App {
...
@@ -24,7 +56,6 @@ public class App {
foo
.
initBets
(
nbHumanPlayers
,
nbBasicAi
,
nbAdvancedAi
);
foo
.
initBets
(
nbHumanPlayers
,
nbBasicAi
,
nbAdvancedAi
);
foo
.
runGame
();
foo
.
runGame
();
}
scanner
.
close
();
}
}
}
}
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