This class is a factory that provides concrete implementations of the
Bar
abstract class.
Methods
Method get()
Obtain a concrete implementation of the abstract Bar
class of the specified type.
Arguments
type
A character string specifying the type of the
Bar
to instantiate. Possible values are"modern"
and"basic"
. See the Details section for more information.
Details
When type = "modern"
a ModernBar
instance is created
and returned. When type = "basic"
a BasicBar
instance
is provided instead.
Returns
A concrete implementation of the class Bar
. It throws an
error if the requested bar type
is not supported.
Examples
# Create a bar factory.
bar_factory <- BarFactory$new()
# Get a modern bar instance.
bar <- bar_factory$get("modern")
# Check the class of the bar instance.
class(bar)
#> [1] "ModernBar" "Bar" "R6"
# Get a basic bar instance.
bar <- bar_factory$get("basic")
# Check the class of the bar instance.
class(bar)
#> [1] "BasicBar" "Bar" "R6"