Skip to content

Commit

Permalink
Merge pull request #8 from baylagas/dev/composition
Browse files Browse the repository at this point in the history
feat: dev/composition
  • Loading branch information
baylagas authored Mar 4, 2021
2 parents f74a044 + 0c4c91f commit 759b55a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Ortus-Folder/Composition/Company.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
component accessors="true"
{
property name="name";
property name="yearFounded";
property name="departmentArray" type="array";

public any function init(pName, pYearFounded)
{
setName(arguments.pName);
setYearFounded(arguments.pYearFounded);
setDepartmentArray(arrayNew(1));

return this;
}

public function showCompanyInfo(){
writeOutput("<p>name: #getName()#</p>");
writeOutput("<p>year founded: #getYearFounded()#</p>");
writeOutput("<p>department list:</p>");

for (department in getDepartmentArray()){
department.showDepartmentInfo();
}
}

public function addDepartment(pDeparment){
getDepartmentArray().append(pDeparment);
}
}
14 changes: 13 additions & 1 deletion Ortus-Folder/Composition/index.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
<cfset dept1.addEmployee(emp2)>
<cfset dept1.addEmployee(emp3)>

<cfset dept1.showDepartmentInfo()>
<!--- <cfset dept1.showDepartmentInfo()> --->

<cfset comp1 = new Company("artcode", 2013)>

<cfset comp1.addDepartment(dept1)>

<cfset dept2 = new Department("Finance", "3")>
<cfset dept3 = new Department("HR", "2")>

<cfset comp1.addDepartment(dept2)>
<cfset comp1.addDepartment(dept3)>

<cfset comp1.showCompanyInfo()>

0 comments on commit 759b55a

Please sign in to comment.