diff --git a/OOPP.py b/OOPP.py new file mode 100644 index 0000000..1f7a6ef --- /dev/null +++ b/OOPP.py @@ -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()) diff --git a/game_of_sticks.py b/game_of_sticks.py new file mode 100644 index 0000000..788d235 --- /dev/null +++ b/game_of_sticks.py @@ -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() diff --git a/test_game_of_sticks.py b/test_game_of_sticks.py new file mode 100644 index 0000000..e69de29