From abf49f34dc5af564dbd550bb9c9b44d4ad290ed3 Mon Sep 17 00:00:00 2001 From: HannesOberreiter Date: Mon, 14 Jun 2021 21:04:17 +0200 Subject: [PATCH] Update 14_R6.Rmd - 12.2 Controlling access Added a test case to Q1 of 12.2 Controlling access. The test case is to answer the question: `Create a bank account class that prevents you from directly setting the account balance` --- 14_R6.Rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/14_R6.Rmd b/14_R6.Rmd index 57d37db6..3cedb491 100755 --- a/14_R6.Rmd +++ b/14_R6.Rmd @@ -270,11 +270,12 @@ BankAccountStrict2 <- R6Class( ) ``` -To test our new class, we create an instance and try to go into overdraft. +To test our new class, we create an instance and try to directly set the account balance and try to go into overdraft. ```{r, error = TRUE} my_account_strict_2 <- BankAccountStrict2$new() +my_account_strict_2$balance <- 10 my_account_strict_2$deposit(5) my_account_strict_2$withdraw(10) ```