日期:2014-05-20 浏览次数:20698 次
package TEST;
import java.util.HashMap;
import java.util.Collection;
import java.util.Iterator;
import TEST.Shift;
public class WorkDate {
private Integer _day;
private HashMap _shifts = new HashMap(7);
public WorkDate(int i){
this();
_day = i;
}
public WorkDate(){
//创建班次
for(int i = 1;i <= 3;i++){
this.addShift(new Shift(i));
}
}
public Integer getDay(){
return _day;
}
public void setDay(Integer d){
_day = d;
}
public void addShift(Shift s){
s.setWorkDate(this);
_shifts.put(s.getNo(), s);
}
public Collection getShifts(){
return _shifts.values();
}
public boolean containsWorker(Worker w){
for(Shift s : this.getShifts())
//Type mismatch: cannot convert from element type Object to Shift
{
if (s.containsWorker(w)){
return true;
}
}
return false;
}
}
//Shift.java
package TEST;
public class Shift implements Comparable<Shift> {
private Integer _no;
public Shift() {
}
public Shift(int i) {
_no = i;
}
public Integer getNo() {
return _no;
}
public void setNo(Integer i) {
_no = i;
}
private WorkDate _date;
public WorkDate getWorkDate() {
return _date;
}
public void setWorkDate(WorkDate d) {
_date = d;
}
private Worker _driver;
private Worker _assistant1;
private Worker _assistant2;
public Worker getDriver() {
return _driver;
}
public void setDriver(Worker w) {
_driver = w;
}
public Worker getAssistant1() {
return _assistant1;
}
public void setAssistant1(Worker w) {
_assistant1 = w;
}
public Worker getAssistant2() {
return _assistant2;
}
public void setAssistant2(Worker w) {
_assistant2 = w;
}
public boolean containsWorker(Worker w) {
return _driver == w || _assistant1 == w || _assistant2 == w;
}
public boolean isDone() {
return _driver != null && _assistant1 != null && _assistant2 != null;
}
public int compareTo(Shift s) {