Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Java1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Matthias Hoffmann
Java1
Commits
24fbd24b
Commit
24fbd24b
authored
5 years ago
by
mh16842
Browse files
Options
Downloads
Patches
Plain Diff
updated Pasch
parent
a79a269d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Übungsblatt 5/src/pasch/Pasch.java
+62
-4
62 additions, 4 deletions
Übungsblatt 5/src/pasch/Pasch.java
with
62 additions
and
4 deletions
Übungsblatt 5/src/pasch/Pasch.java
+
62
−
4
View file @
24fbd24b
...
...
@@ -4,11 +4,33 @@ import java.util.Random;
public
class
Pasch
{
//Wurf: 1, Gewuerfelt: 4, 6, 2
//Wurf: 2, Gewuerfelt: 3, 6, 1
//Wurf: 3, Gewuerfelt: 6, 3, 5
//[...]
//Wurf: 224, Gewuerfelt: 3, 5, 6
//Wurf: 225, Gewuerfelt: 5, 1, 1
//Wurf: 226, Gewuerfelt: 2, 2, 2
//Pasch!
//Einser-, Zweier-, und Dreier-Pasch!
//Einser-Pasch in Wurf: 129
//Zweier-Pasch in Wurf: 226
//Dreier-Pasch in Wurf: 221
//Der Mittelwert pro Wuerfel und Wurf war: 3.584071233789
public
static
void
main
(
String
[]
args
)
{
int
wuerfel1
;
int
wuerfel2
;
int
wuerfel3
;
int
anzahlWuerfe
=
0
;
int
paschZaehler
=
0
;
boolean
Pasch
=
false
;
int
einserCounter
;
int
zweierCounter
;
int
dreierCounter
;
while
(
true
)
{
...
...
@@ -17,15 +39,51 @@ public class Pasch {
wuerfel3
=
new
Random
().
nextInt
(
6
)
+
1
;
anzahlWuerfe
++;
System
.
out
.
println
(
"Wurf, "
+
anzahlWuerfe
+
" Gewuerfelt, "
+
wuerfel1
+
", "
+
wuerfel2
+
", "
+
wuerfel3
);
setPause
(
10
);
if
(
wuerfel1
==
wuerfel2
&&
wuerfel1
==
wuerfel3
)
{
break
;
}
}
if
(
wuerfel1
==
1
)
{
Pasch
=
true
;
System
.
out
.
println
(
"Einser-Pasch in Wurf: "
+
anzahlWuerfe
);
paschZaehler
++;
}
else
if
(
wuerfel1
==
2
)
{
Pasch
=
true
;
System
.
out
.
println
(
"Zweier-Pasch in Wurf: "
+
anzahlWuerfe
);
paschZaehler
++;;
}
else
if
(
wuerfel1
==
3
)
{
Pasch
=
true
;
System
.
out
.
println
(
"Dreier-Pasch in Wurf: "
+
anzahlWuerfe
);
paschZaehler
++;
}
else
if
(
paschZaehler
==
3
)
{
break
;
}
System
.
out
.
println
(
"Pasch!"
);
// break;
}
}
System
.
out
.
println
(
"Pasch!\n"
);
System
.
out
.
println
(
"Einser-, Zweier-, und Dreier-Pasch!"
);
}
static
int
setPause
(
int
pause
)
{
try
{
Thread
.
sleep
(
pause
);
}
catch
(
InterruptedException
e
)
{
}
return
0
;
}
}
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