示例#1
0
	def report(self, save=False):

		rep={}

		print('===Начало отчёта===')
		for animal_type in self.animals.keys():

			if len(self.animals[animal_type]) > 0:
				total = 0
				print('==================',animal_type,'==================')

				for i, a in enumerate(self.animals[animal_type]):
					print('=============================================================================')
					print('Животное номер', i+1)
					print ('\tпроизвели ', a.main_product, 'в количестве', a.goods_ready, a.main_product_unit)
					print('\t\tв том числе за последний(е)', self.last_step, 'месяц', a.goods_in_last_month)
					print('\tпробежал', a.distance_traveled, 'км')
					print('\t\tв том числе за последний(е)', self.last_step, 'месяц', a.distance_traveled_in_last_moth)
					print('\tподавал голос', a.voice_used, 'раз(а) за период')
					print('\t\tв том числе за последний(е)', self.last_step, 'месяц', a.voice_in_last_moth)				
					print('=============================================================================')
					total += a.goods_ready

				print('\t', animal_type, 'всего произвели', total, a.main_product_unit, 'продукта', a.main_product, 'за', a.total_moth_in_own, 'месяца на ферме')
				rep[animal_type] = ' '.join(['\t', animal_type, 'всего произвели', str(total), a.main_product_unit, 'продукта', str(a.main_product), 'за', str(a.total_moth_in_own), 'месяца на ферме'])

		print('===Конец отчёта==\n')
		if save == True:
			FarmReportJson.write(rep, 'farm_reports.json')
示例#2
0
# coding: utf-8
from farm import Farm
from jsonreport import FarmReportJson

x = 0

farm = Farm()

farm.report()
rjson = FarmReportJson("farm_reports.json")


def print_module_menu():
    print("возможные действия")
    for i in wwcd:
        print("\t", i)


wwcd = {
    "append animal": farm.append_animal,
    "next": farm.next_month,
    "report": farm.report,
    "menu": print_module_menu,
    "animal types count": None,
    "print from json": None,
}

print_module_menu()

while True:
    try: