c# - Exchanging data between classes -


class = "text"> itemprop = "text">

I have a main square named main, in that main square there is a variable called state which type int in state variable There is a state id that tells the program what it is in (menu, instructions screen ...) in the main category I have the object started with the class of class. Now my question is, how the object has been told that the state has been changed (it is easy, I can make it very easily but the next part is giving me problems), and how the object can tell the main square Is that what he wants to switch states?

This is your question I understand,

  • The main is the controller class that invokes the Sprite example methods
  • state determines the method that is called on it Sprite example

    In this situation, the phantom should have a fixed asset in the class, which is named state (Preferably to be a int instead of a enum

    This is the responsibility of the example methods to update state variables. On completion of the execution of the example method, the collar can check the status that is in the example and then determine the next course of the appropriate action Please.

    A better approach is not to expose the state at all (unless there is no need to use it by external objects). In your case, it appears that the state is being used only to determine the method that is executed (I think you have a switch statement to do this ).

    If you want to cover a particular method based on your situation, then you can leave this decision for yourself as an example, instead of taking the decision of the controller, The method can be ( update () or Execute () ) that performs operations on the basis of operation context (like menu options, etc.). This method can execute the internal method based on the stable state member.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -