testing mwc

This commit is contained in:
Cory 2024-02-12 10:10:56 -05:00
parent 80d5956eac
commit 7c37816f42
3 changed files with 14 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
__pycache__/*

2
die.py
View File

@ -14,4 +14,4 @@ class Die:
def roll(self):
self.face = randint(1, 6)
return self.face
return self.face

View File

@ -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: