Implementing cryptocurrency assets using S4 classes
Now, we will implement our next abstraction with the least number of dependencies, Asset
. We will implement it using S4, and it only depends on TimeStamp
. We define its class using the standard methods shown before, and its attributes include email
to identify what user an asset belongs to, a timestamp
to identify the asset at a point in time, a name
to know what asset we're dealing with, a symbol
to identify the asset type within our system, a total
to record how much of that asset a user has, and an address
to identify what wallet the asset belongs to (a user may have several wallets for the same type of asset):
setClass( Class = "Asset", representation = representation( email = "character", timestamp = "character", name = "character", symbol = "character", total = "numeric", address = "character" ) )
Note that instead of using the S3 class for TimeStamp
in the timestamp
attribute...