Created
November 14, 2021 17:41
-
-
Save Paul-cbt/1d89785d649fa040238445d1c9127015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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