Posted on 2006-11-26 20:23
黑夜ちつ独行者 阅读(230)
评论(0) 编辑 收藏
首先我们先建立一个接口StudnetDao
public interfaces StudentDao{
public void insert(Student student);
}
再用一个类来实现该接口
public class StudentDaoimp implements StudentDao{
public void insert(Student student){
}
}
用一个工厂来产生对象
public class DaoFactory{
public static StudentDao getStudentDao(){
return new StudentDaoimp();
}
}
public class Student{
private int studentID;
public int getStudentID() {
return studentID;
}
public void setStudentID(int age) {
this.studentID= studentID;
}
}