论坛首页 Java企业应用论坛

我工作的那点事--学习《设计模式》实例应用(factory模式)

浏览 1291 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-01-24   最后修改:2010-02-22
  如果您的公司效率不好,或者现在的公司不太适合你,要为以后做准备了,开始慢慢找工作了,于是准备简历了。

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.给自己想进的公司投完简历,呵呵,下面就准备面试,得到自己想要的薪水,准备大干吧,呵呵
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics