???????????????????????????????????????????????????????????

ParticipantsInDB partsInDB = ...;
Participant kent = new Participant(...);
Participant paul = new Participant(...);
partsInDB.clear();
partsInDB.addParticipant(kent);
partsInDB.addParticipant(paul);
partsInDB.deleteParticipant(kent.getId());
System.out.println("There are "+partsInDB.getCount()+ "participants");


????????д???????????There are 1 participants?????????????????????????????There are 2 participants???????????е??????DBTable????????????getCount????????ParticipantsInDB??countParticipants??getCount??????????????????£??????????????????????????????????Щ??????Ч??λ?????????????false?????

??????????Щ?????????????????????

????ParticipantsInDB?????????DBTable???????????clear??getCount??????ParticipantsInDB??????clear????????????????????????е?λ??????getCount?????????С??????????ParticipantsInDB????getCount???????????????participants????????????е?????????????????true????false?????????????????????????????????????????????????????y???getCount???????????????????????????е????Ч???λ?????????????????

????????ParticipantsInDB??????????ü?????????getCount????????????????????????????

??????????????????м?й????

???????????????Щ????????????????????????????????????????????????м?й????ParticipantsInDB?????????DBTable??ParticipantsInDB????????????????????DBTable??

??????????ParticipantsInDB???????????????е?λ??????????????????????????????????????????????????????????????????????????Participants????????????????????????????Participants???????

?????????????????????????????????????磬???????????????2000???λ????????????????д????????????A??participants??????????1000???λ?????????B??participants?????????1000???λ????DBTable????????????????????????????????1000???λ??????participants????????????????2000??λ??????????????????????????????????е?????????????????e????????????????????????????????????????????????????????????????????

????????????????ж??ParticipantsInDB??DBTable????????????е?????ParticipantsInDB??????DBTable?????????????????ParticipantsInDB????getCount??????????????ParticipantsInDB?????DBTable????????????????????????????????????????ParticipantsInDB?????????????DBTable??

public class DBTable {
private Connection conn;
private String tableName;
public DBTable(String tableName) {
this.tableName = tableName;
this.conn = ...;
}
public void clear() {
PreparedStatement st = conn.prepareStatement("DELETE FROM "+tableName);
{
st.executeUpdate();
}finally{
st.close();
}
}
public int getCount() {
PreparedStatement st = conn.prepareStatement("SELECT COUNT(*) FROM "+tableName);
try {
ResultSet rs = st.executeQuery();
rs.next();
return rs.getInt(1);
}finally{
st.close();
}
}
public String getTableName() {
return tableName;
}
public Connection getConn() {
return conn;
}
}
public class ParticipantsInDB {
private DBTable table;
public ParticipantsInDB() {
table = new DBTable("participants");
}
public void addParticipant(Participant part) {
...
}
public void deleteParticipant(String participantId) {
setDeleteFlag(participantId?? true);
}
public void restoreParticipant(String participantId) {
set