1 25 26 package org.objectweb.speedo.tutorial.pobjects.additional.inheritance; 27 28 import java.util.ArrayList ; 29 import java.util.Collection ; 30 import java.util.Iterator ; 31 32 33 34 37 public class Manager extends Employee { 38 39 private String team; 40 private Collection workers; 41 42 public Manager(String name, int age, String company, String team) { 43 super(name, age, company, "manager"); 44 this.team = team; 45 this.workers = new ArrayList (); 46 } 47 48 public String getTeam() { 49 return team; 50 } 51 52 public void setTeam(String team) { 53 this.team = team; 54 } 55 56 public Collection getWorkers() { 57 return workers; 58 } 59 public void setWorkers(Collection workers) { 60 this.workers = workers; 61 } 62 public void addWorker(Worker worker){ 63 workers.add(worker); 64 } 65 66 public String toString(){ 67 String s = "Manager: Employee(" + super.toString() + "), team=" + team; 68 if(workers.size() > 0){ 69 s += ", list of workers["; 70 Iterator it = workers.iterator(); 71 while(it.hasNext()){ 72 Worker worker = (Worker) it.next(); 73 s += worker.getName() + ", "; 74 } 75 s = s.substring(0, s.length()-2); 76 s += "]"; 77 } 78 return s; 79 } 80 } 81 | Popular Tags |