guys I know im supposed to do this but i've been pulling my hair out for the past 3 hours can anyone help ? I'm trying to create a Object oriented program that will :
Each user starts with a list of numbers from 1 to 6. They then take turns throwing a dice, aiming to throw each number in the list.
Show the numbers of the user each time around the main game loop, showing an X for a number they have already, e.g.Starting
[1][2][3][4][5][6]
after 3 throws:
[1][X][X][4][X][6]
The game is complete when the player gets all numbers in the list.
For starters
[1,2,3,4,5,6]
>>59608779
I'm too lazy to do your homework.
import random
class game:
nums = [x for x in range(1,7)]
def throw(self):
t = random.randint(1,6)
print(t)
self.nums = [x for x in self.nums if x != t]
def isFinished(self):
return (len(self.nums) == 0)
b = game()
while not b.isFinished():
b.throw()
print(b.nums)
Uhm thanks !!!! that'll be more than enough the code is a bit complicated but i'll understand
Create class for player. Player has number list containing numbers 1 to 6. You can give them names or other stupid shit if you want.
Put each created player into a list.
Create variables. One being turn, set to 0. Another being winner, set to empty string.
Put program in never ending loop.
Get player object. A = player_list[ turn % len(player_list)]
...
Do shit
...
Turn += 1
Break out of loop if player number list is empty
Print the faggot winner
There I did half your work.
Also
>Python 2
>>59609002
Thanks !!!
So each player is playing with the same random list?
>>59609164
Yes the other player is the computer but they are playing from the same list
why don't you just install gentoo then runimport homework
homework.run()
import rope
hang.outofawindow()
>>59609228
thanks