필터 지우기
필터 지우기

Class with no initial properties

조회 수: 3 (최근 30일)
Bert
Bert 2011년 10월 6일
Hey all,
3 classes have been defined in my project:
testClass which contain patients.
Patients are from the type patientClass, which contain an ID and data.
The data is from the type dataClass, which contain results.
If I want to make a test from the type testClass with a constructor:
test = testClass();
I don't want it to have any patients yet. Instead, patients should be added through a class method of testClass:
addPatient(idNumber) as such:
test.addPatient('12345');
Same goes with data in patients and results in data.
Is this doable or am I missing the point here?
Maybe I should define the patients of testClass as a group. In that case I would have a group of patients (maybe an array of objects? I still think this is not really OOP-minded though) upon creation of the trial, which in turn can be empty (or which's size can be defined along with the constructor).
Any suggestions are much appreciated!

채택된 답변

Daniel Shub
Daniel Shub 2011년 10월 6일
You can do this. When you define the patients property in testClass, just initialize it to be empty.
classdef testClass
properties
patients = patientClass.empty;
end
...
end
  댓글 수: 1
Bert
Bert 2011년 10월 6일
Daniel, thanks again!
It looks like I've been asking the wrong questions (or the right ones, but in a wrong way), because I didn't come across this possibility while searching the documentation, this forum or google. Now that I know what to look for (i.e. empty property), I found it in the documentation as well!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by