我工作的那點事--學習《設計模式》例項應用(factory模式)

biqing0427發表於2007-11-20

[@more@]最近公司效率不好,不斷地裁員,自己也感到有壓力,要為以後做準備了,開始慢慢找工作了,於是準備簡歷了。

1.Person 個人資訊類:

public class Person{

private String name;
private String sex;
private int workTime;
private String companyName;
private String address;
private String proxExperience;
………………

public Person(){
}

public void setName(String name){
this.name = name;
}

public String getName(){
return name;
}

public void setSex(String sex){
this.sex = sex;
}

public String getSex(){
return sex;
}

public void setWorkTime(int workTime){
this.workTime = workTime;
}

public int getWorkTime(){
return workTime;
}

public void setCompanyName(String companyName){
this.companyName= companyName;
}

public String getCompanyName(){
return companyName;
}

public void setAddress(String address){
this.address= address;
}

public String getAddress(){
return address;
}

public void setProxExperience(String proxExperience){
this.proxExperience= proxExperience;
}

public String getProxExperience(){
return proxExperience;
}
………………
}

2.簡歷寫好了,下面要開始找公司 找職位了,現在有很多途徑:招聘會、網站、朋友推薦,獵頭等等……,
他們就像工廠一樣,根據你的要求,自動生成單位和職位 給你,你不用參與找這些東東產生的過程,也不用你面對一堆單位,不知從哪裡開始找。
2.1 QueryInfo 查詢條件:
public class QueryInfo{

private String city;
private String companyType;
private String jobType;
………………

public QueryInfo(){
}

public void setCity(String city){
this.city = city;
}

public String getCity(){
return city;
}

public void setCompanyType(String companyType){
this.companyType= companyType;
}

public String getCompanyType(){
return companyType;
}

public void setJobType(String jobType){
this.jobType= jobType;
}

public String getJobType(){
return jobType;
}
………………
}

2.2 招聘網站:
CompanyFactory:

public class CompanyFactory{

private Company company = null;

public static Company createCompany(Person person, QueryInfo queryInfo){

if(queryInfo.jobType.equals("a")){
company = new CompanyA();
} else if(queryInfo.jobType.equals("b")){
company = new CompanyB();
} else if(queryInfo.jobType.equals("c")){
company = new CompanyC();
}
……………………
return company;
}

}

2.3 好的公司 和工作
public abstract class Company(){

public abstract void companyInfo();
public abstract void companyType();
public abstract void companyFund();
public abstract void companyJob();

}

public class CompanyA() extends Company{

public void companyInfo(){};
public void companyType(){};
public void companyFund(){};
public void companyJob(){};

}

public class CompanyB() extends Company{

public void companyInfo(){};
public void companyType(){};
public void companyFund(){};
public void companyJob(){};

}

public class CompanyC() extends Company{

public void companyInfo(){};
public void companyType(){};
public void companyFund(){};
public void companyJob(){};

}

3. 一切都準備好了,下面就根據自己的條件,找工作吧:

public void testFactory(){
Person person = new Person();
person.setName("name");
person.setSex("男");
…………

QueryInfo queryInfo = new QueryInfo();
queryInfo.setCompanyType("wolf");
…………

//要找的公司
Company company;

//投簡歷
company = CompanyFactory.createCompanyFactory(person,queryInfo);
}

4.給自己想進的公司投完簡歷,呵呵,下面就準備面試,得到自己想要的薪水,準備大幹吧,呵呵

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9879276/viewspace-983084/,如需轉載,請註明出處,否則將追究法律責任。

相關文章