Advertisement
cepxuozab

inheritance

Apr 2nd, 2023
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. void StudentBehaviorWithSatisfactionSupervisor() {
  2.         Student p("ivan"s, 17);
  3.         SatisfactionSupervisor sup{105, 107};
  4.         p.SetObserver(&sup);
  5.  
  6.         ASSERT_EQUAL(p.GetDanceCount(), 0);
  7.         ASSERT_EQUAL(p.GetSatisfaction(), 100);
  8.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 0);
  9.         p.LiveADay();
  10.         ASSERT_EQUAL(p.GetDanceCount(), 10);
  11.         ASSERT_EQUAL(p.GetSatisfaction(), 107);
  12.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 1);
  13.  
  14.         p.Dance();
  15.         ASSERT_EQUAL(p.GetDanceCount(), 10 + 1);
  16.         ASSERT_EQUAL(p.GetSatisfaction(), 107 + 1);
  17.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 1);
  18.         p.LiveADay();
  19.         ASSERT_EQUAL(p.GetDanceCount(), 10 + 1);
  20.         ASSERT_EQUAL(p.GetSatisfaction(), 107 + 1 - 3);
  21.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 1 + 1);
  22.  
  23.         p.Dance();
  24.         p.Dance();
  25.         ASSERT_EQUAL(p.GetDanceCount(), 10 + 1 + 2);
  26.         ASSERT_EQUAL(p.GetSatisfaction(), 107 + 1 - 3 + 2);
  27.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 1 + 1);
  28.  
  29.         p.Study();
  30.         ASSERT_EQUAL(p.GetDanceCount(), 10 + 1 + 2 + 3);
  31.         ASSERT_EQUAL(p.GetSatisfaction(), 107);
  32.         ASSERT_EQUAL(p.GetKnowledgeLevel(), 1 + 1 + 1);
  33.  
  34.         const auto& p_c = p;
  35.         ASSERT_EQUAL(p_c.GetDanceCount(), 10 + 1 + 2 + 3);
  36.         ASSERT_EQUAL(p_c.GetSatisfaction(), 107);
  37.         ASSERT_EQUAL(p_c.GetKnowledgeLevel(), 1 + 1 + 1);
  38.     }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement