Refer to the DND code (or you may refer to my solution). Rewrite the code such that each character has only one characte
Posted: Thu Jul 14, 2022 2:13 pm
Refer to the DND code (or you may refer to my solution). Rewrite the code such that each character has only one characteristic: Strength. You do NOT have to include the part about writing the file... you can omit that. Each character should just have one attribute: strength. Then, create another monster class that also has a strength characteristic. Use a loop to cycle through the characters, and output who will beat the monster based upon if the character or the monster has a higher strength value. Update the strength of the monster such that every time a character attacks the monster, the monster's strength is depleted by the strength of the character. The minimum value the monster strength can be is 0 . In the event of a tie, the character wins.
Please enter the number of characters you wish to hav Please enter a name: Will Please enter Will's strength: 7 Please enter a name: Mike Please enter Mike's strength: 4 Please enter a name: Dustin Please enter Dustin's strength: 9 Please enter a name: Lucas Please enter Lucas's strength: 6 Please enter the name of the monster: Demogorgon Please enter the monster's strength: 20 Please enter the monster's strength: 20 Will is fighting Demogorgon Demogorgon wins Monster strength: 13 Mike is fighting Demogorgon Demogorgon wins Monster strength: 9 Dustin is fighting Demogorgon Dustin wins Monster strength: 0 Lucas is fighting Demogorgon Lucas wins Monster strength: 0
Please enter the number of characters you wish to hav Please enter a name: Will Please enter Will's strength: 7 Please enter a name: Mike Please enter Mike's strength: 4 Please enter a name: Dustin Please enter Dustin's strength: 9 Please enter a name: Lucas Please enter Lucas's strength: 6 Please enter the name of the monster: Demogorgon Please enter the monster's strength: 20 Please enter the monster's strength: 20 Will is fighting Demogorgon Demogorgon wins Monster strength: 13 Mike is fighting Demogorgon Demogorgon wins Monster strength: 9 Dustin is fighting Demogorgon Dustin wins Monster strength: 0 Lucas is fighting Demogorgon Lucas wins Monster strength: 0