Пример #1
0
        public GirlfriendViewModel()
        {
            myGirlfriend = new Girlfriend("Michella");

            myGirlfriend.ValueChanged += ValueChanged;
            myGirlfriend.StateChanged += StateChanged;
        }
Пример #2
0
 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);
     }
 }
Пример #3
0
 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);
     }
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
 public TiredState(Girlfriend girlfriend) : base(girlfriend)
 {
     // Starts a new Task to run The Tiredness Method
     Task task = Task.Factory.StartNew(() => Tiredness());
 }
Пример #7
0
 public LoveState(Girlfriend girlfriend) : base(girlfriend)
 {
     // Starts a new Task to run The Love Method
     Task task = Task.Factory.StartNew(() => Love());
 }
Пример #8
0
 public bool CheckMatch(Girlfriend gf)
 {
     return(age <= (gf.age + 5) && age >= (gf.age - 1));
 }
Пример #9
0
 public HappyState(Girlfriend girlfriend) : base(girlfriend)
 {
     // Starts a new Task to run The Happyness Method
     Task task = Task.Factory.StartNew(() => Happyness());
 }