package specs;import java.util.Date;
import java.util.GregorianCalendar;public class Model implements Comparable<Model>
{
private String name; //模块的名称
private String function; //模块的功能概述,String字符串描述
private int outManday; // 外报人日
private Programmer[] programmer; //程序员的数组
private int estManday; //项目经理预估人日
private int realManday; //实际花费的人日(编码时间+测试时间)
private Date reqDate; //要求完成的日期
private int codingTime; //程序员编码时间
private int testingTime; //程序员测试时间
public Model(String n, String f, int out, Programmer[] prms, int est, int year, int month, int day)
{
name = n;
function = f;
outManday = out;
programmer = prms;
estManday = est;
// realManday = r;
GregorianCalendar calendar = new GregorianCalendar(year, month, day);
reqDate = calendar.getTime();
}
public String getName()
{
return name;
}
public String getFunction()
{
return function;
}
public int getOutManday()
{
return outManday;
}
public Programmer[] getProgrammer()
{
return programmer;
}
public int getEstManday()
{
return estManday;
}
public int getRealManday()
{
// for(int i = 0; i < programmer.length; i++)
// {
// int[] Manday = new int[programmer.length];
// Manday[i] = programmer[i].getcodingTimeTime()+ programmer[i].getTestingTime();
// realManday += Manday[i];
// }
realManday = codingTime + testingTime;
return realManday;
}
public void setCodingTime(int codingTime)
{
this.codingTime = codingTime;
} public void setTestingTime(int testingTime)
{
this.testingTime = testingTime;
}
public int getCodingTime()
{
return codingTime;
} public int getTestingTime()
{
return testingTime;
} public Date getReqDate()
{
return reqDate;
}
@SuppressWarnings("deprecation")
public int compareTo(Model m)
{
return this.getReqDate().getDay() - m.getReqDate().getDay();
}
}//定义model类
public class Programmer
{
private String id;
private String name;
public Programmer(String id, String name)
{
this.id = id;
this.name = name;
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
// public int getCodingTime()
// {
// return codingTime;
// }
//
// public int getTestingTime()
// {
// return testingTime;
// } public void coding(int ctime, Model m)
{
m.setCodingTime(ctime);
// System.out.println("这个模块的编码由"+ this.getName()+ "完成 ");
// System.out.println("模块"+ m.getName()+ "要求完成的日期是:"+ m.getReqDate());
// System.out.println(m.getName()+ "的编码实际花费人日:"+ m.getCodingTime());
}
public void testing(int ttime, Model m)
{
m.setTestingTime(ttime);
this.getName();
// System.out.println("这个模块的测试由"+ this.getName()+ "完成 ");
// System.out.println("模块"+ m.getName()+ "要求完成的日期是:"+ m.getReqDate());
// System.out.println(m.getName()+ "的测试实际花费人日:"+ m.getTestingTime());
}
public void modifying(String modify, Model m)
{
modify = "完成模块"+ m.getName()+ "的最后修改";
System.out.println(modify);
} public void setId(String id)
{
this.id = id;
} public void setName(String name)
{
this.name = name;
}
}//定义 程序员类
//test类import java.util.*;public class SpecTest
{
// String n, String f, int out, Programmer[] prms, int est,
// int year, int month, int day
public static void main(String[] args)
{
Programmer pro[] = new Programmer[4]; //引用4个程序员的对象
pro[0] = new Programmer("001", "Tom");
pro[1] = new Programmer("002", "Jerry");
pro[2] = new Programmer("003", "Tod");
pro[3] = new Programmer("004", "Moon");
Model[] model = new Model[4]; //定义4个spec模块
model[0] = new Model("模块1", "功能实现1", 3, pro, 2, 2008, 9, 12);
model[1] = new Model("模块2", "功能实现2", 4, pro, 2, 2008, 9, 15);
model[2] = new Model("模块3", "功能实现3", 3, pro, 2, 2008, 9, 13);
model[3] = new Model("模块4", "功能实现4", 5, pro, 2, 2008, 9, 14);
for(int i = 0; i<pro.length; i++)
{
pro[i].coding(2, model[0]);
}// pro[1].coding(2, model[1]);
// pro[2].coding(2, model[2]);
// pro[3].coding(2, model[3]);
pro[0].testing(1, model[0]);
pro[1].testing(2, model[1]);
pro[2].testing(3, model[2]);
pro[3].testing(4, model[3]);
for(Model m : model)
{
System.out.println(m.getName()+ "模块外报人日是"+ m.getOutManday());
System.out.println(m.getName()+ "模块的功能是:"+ m.getFunction());
System.out.println(m.getName()+ "完成该模块的程序员是:"+ m.getProgrammer());//这里帮助下
System.out.println(m.getName()+ "这个模块实际需要的人日:" +m.getRealManday());
System.out.println(m.getName()+ "这个模块要求完成的日期:" +m.getReqDate());
System.out.println("项目经理估计这个模块需要的人日:"+ m.getEstManday());
}
//做一个数组比较日期,然后求出最紧急的两个项目
ArrayList<Model> listModel = new ArrayList<Model>();
listModel.add(model[0]);
listModel.add(model[1]);
listModel.add(model[2]);
listModel.add(model[3]); System.out.println("最急于完成的两个模块是:");
Collections.sort(listModel);
for (int i=0;i<2;i++)
{
Model model_temp=(Model)listModel.get(i);
System.out.println(model_temp.getReqDate()+ model_temp.getName());
}
}
}
我想得到程序员的所有name,一个model是由许多程序员做的测试结果:
模块1模块外报人日是3
模块1模块的功能是:功能实现1
模块1完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块1这个模块实际需要的人日:3
模块1这个模块要求完成的日期:Sun Oct 12 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块2模块外报人日是4
模块2模块的功能是:功能实现2
模块2完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块2这个模块实际需要的人日:2
模块2这个模块要求完成的日期:Wed Oct 15 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块3模块外报人日是3
模块3模块的功能是:功能实现3
模块3完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块3这个模块实际需要的人日:3
模块3这个模块要求完成的日期:Mon Oct 13 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块4模块外报人日是5
模块4模块的功能是:功能实现4
模块4完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块4这个模块实际需要的人日:4
模块4这个模块要求完成的日期:Tue Oct 14 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
最急于完成的两个模块是:
Sun Oct 12 00:00:00 CST 2008模块1
Mon Oct 13 00:00:00 CST 2008模块3
import java.util.GregorianCalendar;public class Model implements Comparable<Model>
{
private String name; //模块的名称
private String function; //模块的功能概述,String字符串描述
private int outManday; // 外报人日
private Programmer[] programmer; //程序员的数组
private int estManday; //项目经理预估人日
private int realManday; //实际花费的人日(编码时间+测试时间)
private Date reqDate; //要求完成的日期
private int codingTime; //程序员编码时间
private int testingTime; //程序员测试时间
public Model(String n, String f, int out, Programmer[] prms, int est, int year, int month, int day)
{
name = n;
function = f;
outManday = out;
programmer = prms;
estManday = est;
// realManday = r;
GregorianCalendar calendar = new GregorianCalendar(year, month, day);
reqDate = calendar.getTime();
}
public String getName()
{
return name;
}
public String getFunction()
{
return function;
}
public int getOutManday()
{
return outManday;
}
public Programmer[] getProgrammer()
{
return programmer;
}
public int getEstManday()
{
return estManday;
}
public int getRealManday()
{
// for(int i = 0; i < programmer.length; i++)
// {
// int[] Manday = new int[programmer.length];
// Manday[i] = programmer[i].getcodingTimeTime()+ programmer[i].getTestingTime();
// realManday += Manday[i];
// }
realManday = codingTime + testingTime;
return realManday;
}
public void setCodingTime(int codingTime)
{
this.codingTime = codingTime;
} public void setTestingTime(int testingTime)
{
this.testingTime = testingTime;
}
public int getCodingTime()
{
return codingTime;
} public int getTestingTime()
{
return testingTime;
} public Date getReqDate()
{
return reqDate;
}
@SuppressWarnings("deprecation")
public int compareTo(Model m)
{
return this.getReqDate().getDay() - m.getReqDate().getDay();
}
}//定义model类
public class Programmer
{
private String id;
private String name;
public Programmer(String id, String name)
{
this.id = id;
this.name = name;
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
// public int getCodingTime()
// {
// return codingTime;
// }
//
// public int getTestingTime()
// {
// return testingTime;
// } public void coding(int ctime, Model m)
{
m.setCodingTime(ctime);
// System.out.println("这个模块的编码由"+ this.getName()+ "完成 ");
// System.out.println("模块"+ m.getName()+ "要求完成的日期是:"+ m.getReqDate());
// System.out.println(m.getName()+ "的编码实际花费人日:"+ m.getCodingTime());
}
public void testing(int ttime, Model m)
{
m.setTestingTime(ttime);
this.getName();
// System.out.println("这个模块的测试由"+ this.getName()+ "完成 ");
// System.out.println("模块"+ m.getName()+ "要求完成的日期是:"+ m.getReqDate());
// System.out.println(m.getName()+ "的测试实际花费人日:"+ m.getTestingTime());
}
public void modifying(String modify, Model m)
{
modify = "完成模块"+ m.getName()+ "的最后修改";
System.out.println(modify);
} public void setId(String id)
{
this.id = id;
} public void setName(String name)
{
this.name = name;
}
}//定义 程序员类
//test类import java.util.*;public class SpecTest
{
// String n, String f, int out, Programmer[] prms, int est,
// int year, int month, int day
public static void main(String[] args)
{
Programmer pro[] = new Programmer[4]; //引用4个程序员的对象
pro[0] = new Programmer("001", "Tom");
pro[1] = new Programmer("002", "Jerry");
pro[2] = new Programmer("003", "Tod");
pro[3] = new Programmer("004", "Moon");
Model[] model = new Model[4]; //定义4个spec模块
model[0] = new Model("模块1", "功能实现1", 3, pro, 2, 2008, 9, 12);
model[1] = new Model("模块2", "功能实现2", 4, pro, 2, 2008, 9, 15);
model[2] = new Model("模块3", "功能实现3", 3, pro, 2, 2008, 9, 13);
model[3] = new Model("模块4", "功能实现4", 5, pro, 2, 2008, 9, 14);
for(int i = 0; i<pro.length; i++)
{
pro[i].coding(2, model[0]);
}// pro[1].coding(2, model[1]);
// pro[2].coding(2, model[2]);
// pro[3].coding(2, model[3]);
pro[0].testing(1, model[0]);
pro[1].testing(2, model[1]);
pro[2].testing(3, model[2]);
pro[3].testing(4, model[3]);
for(Model m : model)
{
System.out.println(m.getName()+ "模块外报人日是"+ m.getOutManday());
System.out.println(m.getName()+ "模块的功能是:"+ m.getFunction());
System.out.println(m.getName()+ "完成该模块的程序员是:"+ m.getProgrammer());//这里帮助下
System.out.println(m.getName()+ "这个模块实际需要的人日:" +m.getRealManday());
System.out.println(m.getName()+ "这个模块要求完成的日期:" +m.getReqDate());
System.out.println("项目经理估计这个模块需要的人日:"+ m.getEstManday());
}
//做一个数组比较日期,然后求出最紧急的两个项目
ArrayList<Model> listModel = new ArrayList<Model>();
listModel.add(model[0]);
listModel.add(model[1]);
listModel.add(model[2]);
listModel.add(model[3]); System.out.println("最急于完成的两个模块是:");
Collections.sort(listModel);
for (int i=0;i<2;i++)
{
Model model_temp=(Model)listModel.get(i);
System.out.println(model_temp.getReqDate()+ model_temp.getName());
}
}
}
我想得到程序员的所有name,一个model是由许多程序员做的测试结果:
模块1模块外报人日是3
模块1模块的功能是:功能实现1
模块1完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块1这个模块实际需要的人日:3
模块1这个模块要求完成的日期:Sun Oct 12 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块2模块外报人日是4
模块2模块的功能是:功能实现2
模块2完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块2这个模块实际需要的人日:2
模块2这个模块要求完成的日期:Wed Oct 15 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块3模块外报人日是3
模块3模块的功能是:功能实现3
模块3完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块3这个模块实际需要的人日:3
模块3这个模块要求完成的日期:Mon Oct 13 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
模块4模块外报人日是5
模块4模块的功能是:功能实现4
模块4完成该模块的程序员是:[Lspecs.Programmer;@3e25a5
模块4这个模块实际需要的人日:4
模块4这个模块要求完成的日期:Tue Oct 14 00:00:00 CST 2008
项目经理估计这个模块需要的人日:2
最急于完成的两个模块是:
Sun Oct 12 00:00:00 CST 2008模块1
Mon Oct 13 00:00:00 CST 2008模块3
解决方案 »
- replaceAll 替换特定字符的问题
- 用swing实现一种JTable的效果
- Statement类的问题
- 一个sql select语句中有需要输入的变量,如何重组sql在变量输入少或者没有的情况下保证sql还是能正确执行
- 问一个很菜的问题,拜托各位了!
- 如何培养逻辑思维?
- Smack开发Web即时通信
- 如何判断点击了哪个按钮?
- 想考SCJP,没什么信心,问问各位的意见。
- 这是什么问题:java.lang.InstantiationException: `net.cnnic.registrar.RRPClientSession' has no public zero-arg constructor
- preparedStatement 是驱动问题么?
- 要通过一个事件关闭当前的对话框该用那个语句啊!
{
...
String toString(){
return this.name;
}
...
}System.out.println(m.getName()+ "完成该模块的程序员是:"
+ Arrays.deepToString(m.getProgrammer()));
当然循环输出也可以