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

Nowhere near done #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
51 changes: 51 additions & 0 deletions OOPP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@



class Car():
def exclaim(self):
print("IM A CAR")


class Yugo(Car):
def exclaim(self):
return print('Im almost like a car, just a bit different')

def need_a_push(self):
return print("Please push me!!!!!!")


class Person(Yugo):
def __init__(self, name, job):
self.name = input("what is your name?")
self.job = job




phish = Person('keith','Keyboardist')
print('The mighty player:', phish.name, 'and my job is:', phish.job)


print(phish.exclaim())
print(phish.need_a_push())
# class Member(Person):
# def __init__(self, name, job):
# self.name = "Member: "+ name
# self.job = "Job: "+ job
# class Lawyers(Person):
# def __init__(self, name, job):
# self.name = 'Lawyer:'+ name
# self.job = 'Job: '+ job

# person = Member("FIshman",'Drummer')
# lawyer = Lawyers("Cochran", "defend the innocent?")
#
# print(person.name, person.job)
# print(lawyer.name, lawyer.job)
#
# give_me_a_car = Car()
# give_me_a_yugo = Yugo()
# give_me_a_yugo.need_a_push()
# print()
# print(give_me_a_car.exclaim())
# print(give_me_a_yugo.exclaim())
71 changes: 71 additions & 0 deletions game_of_sticks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os



class Player:

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


class Game():

def __init__(self,player1,player2):
self.player1 = player1
self.player2 = player2
self.sticks = 55
self.current_player = self.player1




def switch_players(self):
if self.current_player == self.player1:
print("{} it is now your turn".format(self.player1))
self.current_player = self.player2
else:
self.current_player = self.player1
print("{} its your turn".format(self.player2))

def pile(self):
return "Pile has {} stick(s)".format(self.sticks) \
+ (" / " * self.sticks)

def begin_game(self):
os.system('clear')
print(self.pile())
self.switch_players()
while self.sticks > 1:
self.need_choice()
if self.sticks <= 1:
print("GAmE OveR! {}, WINS".format(self.current_player))
elif self.sticks == 0:
print("GAmE OveR! {}, is the Winner".format(self.current_player))
else:
self.need_choice()




def need_choice(self):

self.choice = input('How many sticks would you like to pick up?(1-3) {}:')
try:
int(self.choice)
except:
print('Please enter a valid choice(1-3)')
self.need_choice()
self.choice = int(self.choice)
if self.choice > 0 and self.choice <= 3:
how_many_sticks = self.choice
self.sticks = self.sticks - how_many_sticks
else:
print('please enter a valid choice')
self.need_choice()
print(self.pile())
self.switch_players()


if __name__ == '__main__':
g1 = Game('Keith','Devil')
g1.begin_game()
Empty file added test_game_of_sticks.py
Empty file.