Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!"package:R6" %in% search()) {
- library(R6)
- }
- # ----------------------
- # Class
- # ----------------------
- Game <- R6Class("Game",
- public = list(
- # Properties:
- a = 0,
- b = 0,
- sum = 0,
- # Functions:
- run = function() {
- part_1()
- part_2()
- part_3()
- },
- part_1 = function() {
- self$a = 10
- return(self$a)
- },
- part_2 = function() {
- self$b = 20
- return(self$b)
- },
- part_3 = function() {
- self$sum = self$a + self$b
- return(self$sum)
- }
- )
- )
- # Instantiate an object base on a class.
- game <- Game$new()
- # Run function that runs through all other functions.
- game$run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement