diff --git a/Dice_Rolling_Stimulator/dice_stimulator.py b/Dice_Rolling_Stimulator/dice_stimulator.py index 1263bb6e..de691ce0 100644 --- a/Dice_Rolling_Stimulator/dice_stimulator.py +++ b/Dice_Rolling_Stimulator/dice_stimulator.py @@ -1,71 +1,79 @@ import random -#CATEGORIZING OUTCOME INTO A LIST -one = """ - ("===========") - ("| |") - ("| O |") - ("| |") - ("===========")\n - - """ +class DiceSimulator: + """ + A class to simulate rolling two dice. + + Features: + - Randomly rolls two dice with ASCII representation. + - Offers user the option to roll again or quit. + """ -two = """ - ("===========") - ("| |") - ("| O O |") - ("| |") - ("===========")\n - + dice_faces = [ + """ + =========== + | | + | O | + | | + =========== + """, + """ + =========== + | O | + | | + | O | + =========== + """, + """ + =========== + | O | + | O | + | O | + =========== + """, + """ + =========== + | O O | + | | + | O O | + =========== + """, + """ + =========== + | O O | + | O | + | O O | + =========== + """, + """ + =========== + | O O | + | O O | + | O O | + =========== """ + ] - - -three = """ - ("===========") - ("| O |") - ("| O |") - ("| O |") - ("===========")\n - + def roll_dice(self): """ - -four = """ - ("===========") - ("| O O |") - ("| 0 |") - ("| O O |") - ("===========")\n - + Rolls two dice and prints their ASCII representation. """ + dice_rolls = random.choices(self.dice_faces, k=2) + for die in dice_rolls: + print(die) -five = """ - ("===========") - ("| O O |") - ("| 0 |") - ("| O O |") - ("===========")\n - + def start_game(self): """ - -six = """ - ("===========") - ("| O O |") - ("| O O |") - ("| O O |") - ("===========") \n + Starts the dice rolling game, giving the user the option to roll again. """ + print("🎲 Welcome to the Dice Simulator! 🎲") + while True: + self.roll_dice() + choice = input("Do you want to roll again? (y/n): ").strip().lower() + if choice != 'y': + print("Thanks for playing! Goodbye!") + break - - -outcomes_list = [one, two, three, four, five, six] - - -print("This is a dice stimulator") -x = "y" -while x == "y": - randon_outcome = random.sample(outcomes_list, 2) - for outcome in randon_outcome: - print(outcome) - - x = input("Press y to roll again ") \ No newline at end of file +if __name__ == "__main__": + game = DiceSimulator() + game.start_game()