You are working on a program that simulates a board game. On your turn, you roll two dice to move forward. If you roll the same number on both dice, the next player only rolls one die on their next turn, but if you roll two 3's you don't move forward and your next turn gets skipped. You wrote the following function to handle the rolls. When you get the return value, you know a -1 means the other player loses a die on their next roll, and any other return value is added to your current position. What is wrong with the function and how should you fix it? Select all that apply. def process_roll(roll1, roll2): if rolll == 3 and roll2 == 3: print ("You get skipped! Lose your next turn. :(") if rolll == roll2: print("Your opponent loses a die on their next turn !") return -1 return rolll + roll2 roll2 should have a default value of 1 so the function won't crash when you only roll 1 die. O You need to return 0 when you roll two 3's. O You need to return -1 when you roll two 3's so it doesn't move you forward 6.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 4GZ
icon
Related questions
Question
You are working on a program that simulates a board game. On your turn, you roll two dice to move
forward. If you roll the same number on both dice, the next player only rolls one die on their next turn,
but if you roll two 3's you don't move forward and your next turn gets skipped.
You wrote the following function to handle the rolls. When you get the return value, you know a -1
means the other player loses a die on their next roll, and any other return value is added to your current
position. What is wrong with the function and how should you fix it? Select all that apply.
def process_roll(roll1, roll2):
if rolll == 3 and roll2 == 3:
print ("You get skipped! Lose your next turn. :(")
if rolll ==
roll2:
print("Your opponent loses a die on their next turn !")
return -1
return rolll + roll2
roll2 should have a default value of 1 so the function won't crash when you only roll 1 die.
You need to return 0 when you roll two 3's.
O You need to return -1 when you roll two 3's so it doesn't move you forward 6.
O You don't need to return -1 when the opponent loses a die, just return the total. You can just check the returned
value against 2, 4, 8, 10, and 12 to see if they lose a die.
O Checking for the opponent losing a die should be handled in a separate function.
O rol12 should have a default value of 0 so the function won't crash when you only roll 1 die.
Transcribed Image Text:You are working on a program that simulates a board game. On your turn, you roll two dice to move forward. If you roll the same number on both dice, the next player only rolls one die on their next turn, but if you roll two 3's you don't move forward and your next turn gets skipped. You wrote the following function to handle the rolls. When you get the return value, you know a -1 means the other player loses a die on their next roll, and any other return value is added to your current position. What is wrong with the function and how should you fix it? Select all that apply. def process_roll(roll1, roll2): if rolll == 3 and roll2 == 3: print ("You get skipped! Lose your next turn. :(") if rolll == roll2: print("Your opponent loses a die on their next turn !") return -1 return rolll + roll2 roll2 should have a default value of 1 so the function won't crash when you only roll 1 die. You need to return 0 when you roll two 3's. O You need to return -1 when you roll two 3's so it doesn't move you forward 6. O You don't need to return -1 when the opponent loses a die, just return the total. You can just check the returned value against 2, 4, 8, 10, and 12 to see if they lose a die. O Checking for the opponent losing a die should be handled in a separate function. O rol12 should have a default value of 0 so the function won't crash when you only roll 1 die.
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT