January 2020
Intermediate to advanced
532 pages
13h 31m
English
Now that we understand what to expect from the Vehicle interface, we can develop something that actually implements the interface. We will create a new FighterJets module and define the FighterJet data type as follows:
"FighterJet is a very fast vehicle with powerful weapons."mutable struct FighterJet "power status: true = on, false = off" power::Bool "current direction in radians" direction::Float64 "current position coordinate (x,y)" position::Tuple{Float64, Float64} end
To conform to the Vehicle interface defined previously, we must first import the generic functions from the Vehicle module and then implement the logic for operating the FighterJet vehicle. Here is the code for the power_on and power_off functions: ...
Read now
Unlock full access