MATLAB Object-Oriented Programming

(Joyce) #1

Class with Default Object Display


In this section...
“The EmployeeInfo Class” on page 18-14
“Default Display — Scalar” on page 18-15
“Default Display — Nonscalar” on page 18-15
“Default Display — Empty Object Array” on page 18-16
“Default Display — Handle to Deleted Object” on page 18-17
“Default Display — Detailed Display” on page 18-17

The EmployeeInfo Class


The EmployeeInfo class defines a number of properties to store information about
company employees. This simple class serves as the example class used in display
customization sample classes.

EmployeeInfo derives from the matlab.mixin.CustomDisplay class to enable
customization of the object display.

EmployeeInfo is also a handle class. Therefore instances of this class can be in the state
referred to as a handle to a deleted object. This state does not occur with value classes
(classes not derived from handle).

classdef EmployeeInfo < handle & matlab.mixin.CustomDisplay
properties
Name
JobTitle
Department
Salary
Password
end
methods
function obj = EmployeeInfo
obj.Name = input('Name: ');
obj.JobTitle = input('Job Title: ');
obj.Department = input('Department: ');
obj.Salary = input('Salary: ');
obj.Password = input('Password: ');
end

18 Customizing Object Display

Free download pdf