public GirlfriendViewModel() { myGirlfriend = new Girlfriend("Michella"); myGirlfriend.ValueChanged += ValueChanged; myGirlfriend.StateChanged += StateChanged; }
public async Task Happyness() { while (true) { if (Girlfriend.Happy > 0) { if (Girlfriend.Hunger > 30 && Girlfriend.Love > 70 && Girlfriend.Tired > 70 && Girlfriend.Stinky > 50) { // If all the other states is above their "Minimum" She is Happy Girlfriend.ChangeState(this); } Girlfriend.OnValueChanged(new ValueEventArgs(this, 0)); } // Waits a second before running again await Task.Delay(1000); } }
public async Task Tiredness() { while (true) { if (Girlfriend.Tired > 0) { if (Girlfriend.Tired < 70) { // If Girlfriend.Tired is below 70 she changes state to Tired Girlfriend.ChangeState(this); } // Calls the value Changed method with the decreaser Girlfriend.OnValueChanged(new ValueEventArgs(this, tiredDown)); } // Waits a second before running again await Task.Delay(1000); } }
public async Task Hunger() { while (true) { if (Girlfriend.Hunger > 0) { if (Girlfriend.Hunger < 30) { // If Girlfriend.Love is below 30 she changes state to Love Girlfriend.ChangeState(this); } // Calls the value Changed method with the decreaser Girlfriend.OnValueChanged(new ValueEventArgs(this, hungryDown)); } // Waits a second before running again await Task.Delay(1000); } }
public async Task Stinkyness() { while (true) { if (Girlfriend.Stinky > 0) { if (Girlfriend.Stinky < 50) { // If Girlfriend.Stinky is below 50 she changes state to Stinky Girlfriend.ChangeState(this); } // Calls the value Changed method with the decreaser Girlfriend.OnValueChanged(new ValueEventArgs(this, stinkyDown)); } // Waits a second before running again await Task.Delay(1000); } }
public TiredState(Girlfriend girlfriend) : base(girlfriend) { // Starts a new Task to run The Tiredness Method Task task = Task.Factory.StartNew(() => Tiredness()); }
public LoveState(Girlfriend girlfriend) : base(girlfriend) { // Starts a new Task to run The Love Method Task task = Task.Factory.StartNew(() => Love()); }
public bool CheckMatch(Girlfriend gf) { return(age <= (gf.age + 5) && age >= (gf.age - 1)); }
public HappyState(Girlfriend girlfriend) : base(girlfriend) { // Starts a new Task to run The Happyness Method Task task = Task.Factory.StartNew(() => Happyness()); }