Dreier optimiert
This commit is contained in:
parent
6d20c28e4f
commit
964fc35834
@ -11,6 +11,8 @@ import java.util.concurrent.Flow.Subscriber;
|
|||||||
import java.util.concurrent.SubmissionPublisher;
|
import java.util.concurrent.SubmissionPublisher;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import bandit.util.OhmLogger;
|
import bandit.util.OhmLogger;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -100,7 +102,15 @@ public class Wuerfel implements Runnable // Callable
|
|||||||
|
|
||||||
private synchronized void berechneWert()
|
private synchronized void berechneWert()
|
||||||
{
|
{
|
||||||
data.setValue((int) (1 + 6*Math.random()));
|
//data.setValue((int) (1 + 6*Math.random()));
|
||||||
|
if(data.getValue() <= 6){
|
||||||
|
data.setValue(data.getValue()+1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
data.setValue(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getValue(){
|
public synchronized int getValue(){
|
||||||
|
@ -66,16 +66,30 @@ public class Zahlengenerator implements Subscriber<WuerfelData> // Callable
|
|||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
lg.info("Generator gestopt");
|
lg.info("Generator gestopt");
|
||||||
|
int w1_value = wuerfel_1.getValue();
|
||||||
|
int w2_value = wuerfel_2.getValue();
|
||||||
|
int w3_value = wuerfel_3.getValue();
|
||||||
|
|
||||||
|
lg.info("Aktuelle Zahl in Wuerfel 1: "+ wuerfel_1.getValue());
|
||||||
|
lg.info("Aktuelle Zahl in Wuerfel 2: "+ wuerfel_2.getValue());
|
||||||
|
lg.info("Aktuelle Zahl in Wuerfel 3: "+ wuerfel_3.getValue());
|
||||||
|
|
||||||
|
|
||||||
|
if (w1_value == w2_value && w2_value == w3_value){
|
||||||
|
lg.warning("This user has to much luck, he/she should go to a casino");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lg.warning("unlucky" + w1_value + w2_value + w3_value);
|
||||||
|
|
||||||
|
|
||||||
wuerfel_1.stop();
|
wuerfel_1.stop();
|
||||||
wuerfel_2.stop();
|
wuerfel_2.stop();
|
||||||
wuerfel_3.stop();
|
wuerfel_3.stop();
|
||||||
|
|
||||||
if (wuerfel_1.getValue() == wuerfel_2.getValue() && wuerfel_2.getValue() == wuerfel_3.getValue()){
|
lg.info("Zahl in Wuerfel 1 nach dem Stoppen: "+ wuerfel_1.getValue());
|
||||||
lg.warning("This user has to much luck, he/she should go to a casino");
|
lg.info("Zahl in Wuerfel 2 nach dem Stoppen: "+ wuerfel_2.getValue());
|
||||||
}
|
lg.info("Zahl in Wuerfel 3 nach dem Stoppen: "+ wuerfel_3.getValue());
|
||||||
else
|
|
||||||
lg.warning("unlucky" + wuerfel_1.getValue() + wuerfel_2.getValue() + wuerfel_3.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user