generated from mwc/lab_dice
	testing mwc
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
.DS_Store
 | 
			
		||||
__pycache__/*
 | 
			
		||||
							
								
								
									
										2
									
								
								die.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								die.py
									
									
									
									
									
								
							@@ -14,4 +14,4 @@ class Die:
 | 
			
		||||
 | 
			
		||||
    def roll(self):
 | 
			
		||||
        self.face = randint(1, 6)
 | 
			
		||||
        return self.face
 | 
			
		||||
        return self.face
 | 
			
		||||
							
								
								
									
										11
									
								
								yahtzee.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								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:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user