generated from mwc/lab_dice
Checkpoint 3: While working on Yahtzee, I got to experience Object-Oriented Programming (OOP) by writing classes that represented different parts of the game, such as dice, goals, and the overall Yahtzee game itself. Each class had its own attributes and methods, which made the program easier to organize and understand. For example, the Die class handled rolling and showing values, while the Yahtzee class managed turns, scoring, and game flow. This style of problem-solving is different from the skills in Unit 1 and 2 was mainly focused more on functions and variables whereas in Unit 3 I was able to write out classes with OOP where each class handles its own part of the game. This ultimately makes it easier to make changes, fix bugs, and add new features later on.
22 lines
299 B
Python
22 lines
299 B
Python
from yahtzee import Yahtzee
|
|
from yahtzee_goals import (
|
|
GoalOnes,
|
|
GoalTwos,
|
|
GoalThrees,
|
|
GoalFours,
|
|
GoalFives,
|
|
GoalSixes,
|
|
)
|
|
|
|
goals = [
|
|
GoalOnes(),
|
|
GoalTwos(),
|
|
GoalThrees(),
|
|
GoalFours(),
|
|
GoalFives(),
|
|
GoalSixes(),
|
|
]
|
|
|
|
game = Yahtzee(goals)
|
|
game.play()
|