classdef Motor < ElectricVehicleComponent
properties
CurrentSpeed = 0
SpeedRange = [0, 180]
end
methods
function motor = start(motor,speed)
arguments
motor (1,1) Motor
speed (1,1) {mustBeReal, mustBeNonnegative}
end
if motor.CurrentSpeed > 0
error("Motor:start:MotorAlreadyRunning",...
"Cannot start a motor that is already running.")
end
motor.CurrentSpeed = speed;
end
function motor = stop(motor)
if motor.CurrentSpeed == 0
error("Motor:start:MotorNotRunning",...
"Cannot stop a motor that is not running.")
end
motor.CurrentSpeed = 0;
end
end
end