Created
October 17, 2014 04:53
-
-
Save triplefox/e0457dbeea4073b26e6d to your computer and use it in GitHub Desktop.
example of staticmethod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class Mech(object): | |
def __str__(self): | |
return "Name: %s\n\tweight: %s\n\tslots: %s\n\tmax heat: %s" % (self.name, self.max_weight, self.slots, self.max_heat) | |
@staticmethod | |
def generator(): | |
obj = Mech() | |
obj.name = 'Random Mech '+str(random.randint(0,9999)) | |
obj.weight = random.randint(1,10) | |
obj.slots = random.randint(1,5) | |
obj.hps = -(round(random.randint(0,3) + random.random(),2)) | |
obj.max_weight = 10 | |
obj.max_heat = 10 | |
return obj | |
for n in range(0, 10): | |
print(Mech.generator()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment