Skip to main content
added 31 characters in body; edited title
Source Link
Mast
  • 13.5k
  • 12
  • 54
  • 119

Monty Hall simulation - very first OOP project

Appreciate this project has been done to death but I just want to get a bit of feedback on whether I 'get' OOP or not (this is my first OOP program). Having written a lot of code in a procedural style, I found it quite confusing. Note that the strategies in the strategise method are from the link above. If an unrecognised name is used, it just picks a second door randomly.

Monty Hall simulation - very first OOP project

Appreciate this project has been done to death but I just want to get a bit of feedback on whether I 'get' OOP or not. Having written a lot of code in a procedural style, I found it quite confusing. Note that the strategies in the strategise method are from the link above. If an unrecognised name is used, it just picks a second door randomly.

Monty Hall simulation - OOP

Appreciate this project has been done to death but I just want to get a bit of feedback on whether I 'get' OOP or not (this is my first OOP program). Having written a lot of code in a procedural style, I found it quite confusing. Note that the strategies in the strategise method are from the link above. If an unrecognised name is used, it just picks a second door randomly.

Became Hot Network Question
Tweeted twitter.com/StackCodeReview/status/1401192098259521540
edited body
Source Link
henryn
  • 163
  • 5

My class definitions are in a file called monthHallmontyHall.py:

My class definitions are in a file called monthHall.py:

My class definitions are in a file called montyHall.py:

added 749 characters in body
Source Link
henryn
  • 163
  • 5

What I specifically struggled with are things like:

  • What should be an object? There were lots of things that could have been. Doors, maybe a game show host, maybe the prizes... in the end I kept it simple but that was only after a few iterations and getting stuck.
  • Am I using the classes/methods correctly when running the simulation? Would you surface more of the methods rather than using a 'wrapper' method like I've done with Contestant.play_the_game?
  • The strategise method is a bit of a mess. Is there a better way of implementing this that isn't just a load of if...else?

Any other thoughts/criticisms on general style and anything else are welcome - I don't generally code in Python either so this was all very new.

What I specifically struggled with are things like:

  • What should be an object? There were lots of things that could have been. Doors, maybe a game show host, maybe the prizes... in the end I kept it simple but that was only after a few iterations and getting stuck.
  • Am I using the classes/methods correctly when running the simulation? Would you surface more of the methods rather than using a 'wrapper' method like I've done with Contestant.play_the_game?
  • The strategise method is a bit of a mess. Is there a better way of implementing this that isn't just a load of if...else?

Any other thoughts/criticisms on general style and anything else are welcome - I don't generally code in Python either so this was all very new.

added 19 characters in body
Source Link
henryn
  • 163
  • 5
Loading
Source Link
henryn
  • 163
  • 5
Loading