Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfinished homework #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions game_of_sticks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

class Game:
def __init__(self, player1, player2):
self.player1 = player1
self.player2 = player2
self.current_player = self.player1
self.sticks = 0
self.pick_sticks = 0

def start(self):
self.num_sticks()
print(self.sticks)
while self.sticks > 1:
self.pick_num_sticks()
self.decrement_sticks()
self.loser()


def num_sticks(self):
print("Welcome to the Game of Sticks!")
sticks = int(input("How many sticks are on the table initially (10 - 100)? "))
while sticks < 10 or sticks > 100:
print ("Please enter a number between 10 and 100.")
sticks = int(input("How many sticks are on the table initially (10 - 100)? "))
return sticks


def pick_num_sticks(self):
pick_sticks = int(input("How many sticks do you take (1-3)? "))
while pick_sticks < 1 or pick_sticks > 3:
print("Please enter a number between 1 and 3.")
pick_sticks = int(input("How many sticks do you take (1-3)? "))
return pick_sticks


def decrement_sticks(self):
self.sticks -= self.pick_sticks


def switch_players(self):
if self.current_player == self.player1:
self.current_player = self.player2
else:
self.current_player = self.player1


def loser(self):
if self.total_sticks == 1:
self.current_player = self.player1
else:
self.current_player = self.player2


class Player:
def __init__(self, name):
self.name = name


if __name__ == '__main__':
p1 = Player("Player1")
p2 = Player("Player2")
game = Game(p1, p2)
game.start()