Submarine | R Documentation |
Model the position of a submarine
Model the position of a submarine
position
horizontal position
depth
vertical depth
forward()
Move forward
Submarine$forward(x = 1)
x
forward distance to add
down()
Move down
Submarine$down(x = 1)
x
depth to add
up()
Move up
Submarine$up(x = 1)
x
depth to subtraxt
move()
Move based on a set of commands
Submarine$move(commands)
commands
vector of commands such as "forward 1", "down 2"
clone()
The objects of this class are cloneable with this method.
Submarine$clone(deep = FALSE)
deep
Whether to make a deep clone.
dat <- "forward 5
down 5
forward 8
up 3
down 8
forward 2"
x <- strsplit(dat, "\n")[[1]]
s <- Submarine$new()
s$move(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.