1classdef Temperature
2 properties
3 celsius = 0
4 end
5 methods
6 function obj = Temperature(c)
7 if nargin > 0, obj.celsius = c; end
8 end
9 function f = fahrenheit(obj)
10 % Uses a private helper method to do the conversion.
11 f = obj.toF(obj.celsius);
12 end
13 end
14 methods (Access = private)
15 function f = toF(~, c)
16 f = c * 9 / 5 + 32;
17 end
18 end
19end