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
import 'dart:math'; | |
int nombreExecution = 1000000; | |
void main(List<String> arguments) { | |
Status getNextStatus(Status currentStatus) { | |
var random = Random(); | |
switch (currentStatus) { | |
case Status.dormir: | |
if (random.nextInt(10) == 1) { |
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
import 'dart:math'; | |
int numberOfRuns = 1000000; | |
void main(List<String> arguments) { | |
Status getNextStatus(Status currentStatus) { | |
var random = Random(); | |
switch (currentStatus) { | |
case Status.sleep: | |
if (random.nextInt(10) == 1) { |
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
enum Status { | |
dormir, | |
reveil, | |
manger, | |
exercice, | |
} |
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
class Resultat { | |
int numberOfDormir; | |
int numberOfMangeoire; | |
int numberOfRoue; | |
Resultat({ | |
required this.numberOfDormir, | |
required this.numberOfMangeoire, | |
required this.numberOfRoue, | |
}); |
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 { |
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
Resultat run(Status baseStatus) { | |
var currentStatus = baseStatus; | |
var numberOfDormir = 0; | |
var numberOfMangeoire = 0; | |
var numberOfRoue = 0; | |
return Resultat( | |
numberOfDormir: numberOfDormir, | |
numberOfMangeoire: numberOfMangeoire, |
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
Resultat run(Status baseStatus) { | |
var currentStatus = baseStatus; | |
var numberOfDormir = 0; | |
var numberOfMangeoire = 0; | |
var numberOfRoue = 0; | |
for (var i = 0; i < nombreExecution; i++) { | |
switch (currentStatus) { | |
case Status.dormir: |
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
const int nombreExecution = 10000000; |
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
void start() { | |
var endResult = | |
Resultat(numberOfDormir: 0, numberOfMangeoire: 0, numberOfRoue: 0); | |
var resultDormir = run(Status.dormir); | |
endResult = endResult.add( | |
resultDormir); //faire tourner une fois avec situation intitale dormir | |
var resultReveil = run(Status.reveil); |
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
class Resultat { | |
int numberOfDormir; | |
int numberOfMangeoire; | |
int numberOfRoue; | |
//à ajouter | |
Resultat add(Resultat currentResult) { | |
return Resultat( | |
numberOfDormir: numberOfDormir + currentResult.numberOfDormir, | |
numberOfMangeoire: numberOfMangeoire + currentResult.numberOfMangeoire, |