-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
35 lines (28 loc) · 1.21 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from datetime import datetime
import random
class Generator:
__ANIMAL_FILE_NAME = "animal-names.txt"
__COLOR_FILE_NAME = "colors.txt"
__animals = []
__colors = []
__username = None
def load_data(file_name):
with open(file_name,'r') as file:
for line in file:
if file_name == "animal-names.txt":
Generator.__animals.append(line.strip('\n').replace(" ", "_"))
else:
Generator.__colors.append(line.strip('\n').replace(" ", "_"))
def generate_name():
Generator.load_data(Generator.__ANIMAL_FILE_NAME)
Generator.load_data(Generator.__COLOR_FILE_NAME)
print("Animals size {0}".format(len(Generator.__animals)))
print("Colors siye {0}".format(len(Generator.__colors)))
animal = Generator.__animals[random.randint(0, len(Generator.__animals))]
color = Generator.__colors[random.randint(0, len(Generator.__colors))]
Generator.__username = color + "-" + animal
@staticmethod
def print_output():
Generator.generate_name()
print(datetime.now())
print("Generated name is {0}".format(Generator.__username))