Back to Browse

Python Enum: Refactoring Rock, Paper, Scissors Game

169 views
Jan 19, 2022
7:02

I wrote the first version of this game before Python had the Enum class. Here I show how I improved the code to use this one: class Item(Enum): ROCK = 0 PAPER = 1 SCISSORS = 2 https://github.com/dcbriccetti/python-lessons/commit/f5db0cf800f742570629c2862dd4bb34258b5979 Oops. The comment for the beats function, 'Return the item this item beats' is out of date. It should say, 'Return whether this item beats the given item'.

Download

0 formats

No download links available.

Python Enum: Refactoring Rock, Paper, Scissors Game | NatokHD