Skip to content

Instantly share code, notes, and snippets.

@Paul-cbt
Created November 14, 2021 17:41
Show Gist options
  • Save Paul-cbt/1d89785d649fa040238445d1c9127015 to your computer and use it in GitHub Desktop.
Save Paul-cbt/1d89785d649fa040238445d1c9127015 to your computer and use it in GitHub Desktop.
Status getNextStatus(Status currentStatus) {
var random = Random();
switch (currentStatus) {
case Status.dormir:
if (random.nextInt(10) == 1) {
//une chance sur dix
//one in ten chance
return Status.reveil;
} else {
return Status.dormir;
}
case Status.reveil:
if (random.nextInt(2) == 1) {
//une chance sur deux d'aller manger
return Status.manger;
} else {
//une chance sur deux d'aller faire de l'exercice
return Status.exercice;
}
case Status.manger:
if (random.nextInt(10) < 3) {
//3 chance sur dix d'aller faire de l'exercice
return Status.exercice;
} else {
//7 chance sur dix d'aller dormir
return Status.dormir;
}
case Status.exercice:
if (random.nextInt(10) < 2) {
return Status.exercice;
//2 chances sur dix de continuer l'exercice
} else {
//8 chances sur dix d'aller dormir
return Status.dormir;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment