免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Observer
- [Instructor] How was the coding for the code challenge? Not too bad, right? We already created our subject, which is the code to monitor here. The viewer is our observer and is also created here. To attach the viewer to the core, type c.attach, parentheses, v. Let's set the temperature to 100, which will trigger the viewer to generate a string that says viewer, colon, space, core colon, space, 100, and vertical line. So type c.temp, assignment, 100. Now, let's detach the viewer by typing c.detach, parentheses, and then the viewer, v. Here, we'll set the core temperature to 90, c.temp, assignment, 90, which will not affect the viewer because it's now detached, therefore, no string will be generated in this case, therefore, the overall result is the notification that was generated earlier when the temperature was set to 100, which is viewer, colon, space, core, colon, space, 100, and a vertical line. Click the test my code button. We did it again.
内容
-
-
-
-
-
-
(已锁定)
Observer1 分钟 5 秒
-
(已锁定)
Observer example6 分钟 22 秒
-
(已锁定)
Solution: Observer2 分钟 4 秒
-
(已锁定)
Visitor56 秒
-
(已锁定)
Visitor Example6 分钟 42 秒
-
(已锁定)
Iterator1 分钟 15 秒
-
(已锁定)
Iterator example4 分钟 32 秒
-
(已锁定)
Strategy40 秒
-
(已锁定)
Strategy Example5 分钟 44 秒
-
(已锁定)
Solution: Strategy4 分钟 16 秒
-
(已锁定)
Chain of Responsibility40 秒
-
(已锁定)
Chain of Responsibility example5 分钟 57 秒
-
(已锁定)
-
-