having a simplified class like this that governs a quiz game:
class Game(): def __init__(self,username): ... self.username=username self.question_list=db.getQuestions() self.game_over=False def get_question(self): ... if self.question_list.is_not_empty(): return question def check_answer(answer) ... if answer.is_correct(): self.game_over=False else: self.game_over=True
and having a web controller that receives input parameters such as username, questions and answers. Is it right to use the Game class directly from the controller?
I ask this question because, looking at the controller code, I feel guilty to encode inside some logic; for example, the controller starts the game only when the username is received, and then calls get_question and check_answer in order.
Do you think it is more correct to have another "layer" that receives input parameters from the controller and directly talks to the Game class?
Thanks michelle
, .
, , . , - .
get_question check_answer, , , . , , .
, , , - , , , , -, , , , .
. . .
Source: https://habr.com/ru/post/1731672/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1731667/required-registry-location-common-to-all-users-to-avoid-registry-virtualisation-in-vista&usg=ALkJrhgnRCf-h7nQZ0uxuR3Hq2cErWK13ACan I remove OpenGL vertex arrays after calling glDrawArrays? - c ++События jQuery MouseEnter и MouseOut с .toggle() обратными, когда мышь уже находится над элементом onLoad? - jqueryФотографии в JPanel - javaDynamically updating an html table using JSON using jQuery for a complex object - jsonRegex соответствует первому файлу в файле архивного файла rar. - c#Regular expression to match only the first file in a set of RAR files - ruby | fooobar.comRegex matches the first file in rar archive file installed in Python - pythonThe fastest way to pick up Joomla? - joomlaAccess to a subset of Python class functions - pythonAll Articles