Share your repls and programming experiences

← Back to all posts
game programming
adnan378 (2)

class GamePlayer:
def init(self,name='anonymous',age=0):
self.name=name
self.age=age

def shout(self):
  if(self.age>18):
    print(f"my name is {self.name} and i am {self.age} year old")
  else:
    print(f"u are not elligible for the game {self.name} bcoz ur age is {self.age}")

player1=GamePlayer("adnan",22)
player2=GamePlayer("ahmad",12)
print(player1.name)
print(player2.name)
print(player1.shout())
print(player2.shout())

Commentshotnewtop