From 7c37816f428d63aba2f454833d72ffee683c9e97 Mon Sep 17 00:00:00 2001 From: Cory Date: Mon, 12 Feb 2024 10:10:56 -0500 Subject: [PATCH] testing mwc --- .gitignore | 2 ++ die.py | 2 +- yahtzee.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..473b6e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +__pycache__/* \ No newline at end of file diff --git a/die.py b/die.py index 14580bb..9eb27c6 100644 --- a/die.py +++ b/die.py @@ -14,4 +14,4 @@ class Die: def roll(self): self.face = randint(1, 6) - return self.face + return self.face \ No newline at end of file diff --git a/yahtzee.py b/yahtzee.py index 8ae2b41..e5fc4fd 100644 --- a/yahtzee.py +++ b/yahtzee.py @@ -5,17 +5,28 @@ class Yachtzee: This version of Yahtzee is initialized with a list of goals. """ def __init__(self, goals): + """ This method specifies the default properties of a Yachtzee object. + The object has a score set to 0, a list of goals that is specified when the object is created(?), and a list of five dice. + """ self.score = 0 self.goals = goals self.dice = [Die() for num in range(5)] def play(self): + """ This method allows for a game of Yachtzee to be played. + While none of the goals are met, the game continues. Once a goal is met, the score is printed. + """ print("Welcome to Yachtzee!") while self.count_unused_goals() > 0: self.play_round() print(f"Your final score was {self.score}") def play_round(self): + """ This method allows for a round to be played. + At the start of the round, a divider is printed consisting of 80 = signs. A property called rolls_left is set equal to 3. + Then, all dice are rolled. The method then checks the state (status and goals fulfilled) of the game and updates the score + accordingly. + """ print("=" * 80) self.rolls_left = 3 for die in self.dice: