• Matlab TutorialsNo Comments

    default thumbnail

    Example of Class Definition Syntax

    The following code shows the syntax of a typical class definition. This example is not a functioning class because it references that it does not implement. The purpose of this section is to illustrate various syntactic constructions.

     (ConstructOnLoad) employee < 
       % Class help goes here
       
           % Property help goes here
       end 
    
       properties (Dependent)
          JobTitle
       end 
    
       properties (Transient)
          OfficeNumber
       end 
    
       properties (SetAccess = protected, GetAccess = private)
          EmpNumber
       end 
    
       events
          BackgroundAlert
       end 
    
       
          function Eobj = employee()
             %  help here
                Eobj. = ;
                Eobj.EmpNumber = employee.getEmpNumber;
          end
    
          function result = backgroundCheck(obj)
             result = queryGovDB(obj.,obj.SSNumber);
               if result == false
                  notify(obj,'BackgroundAlert');
               end
          end
    
          function jobt = get.JobTitle(obj)
             jobt = currentJT(obj.EmpNumber);
          end
    
          function .OfficeNumber(obj,setvalue)
             if isInUse(setvalue)
                error('Not available')
             else
                obj.OfficeNumber = setvalue;
             end
          end
       end
    
       methods (Static)
          function num = getEmpNumber
             num = queryDB('LastEmpNumber') + 1;
          end
       end
    end
    You might also be interested in :  Simulation of a Bouncing Ball

    Comment closed!