所以我要发布的这两个文件都在我的数据库包中。DBBinding 类只需要创建一个对象,其中一个字符串作为键,一个字符串作为值。然后 DBrecord 将保留一个 DBBindings 集合,它们都具有相同的键字符串但不同的值字符串。由于某种原因,我无法思考/找到在 DBrecord 中创建 add 方法的正确方法,以便它调用 DBBinding 类/对象构造函数。
这是应该添加绑定的方法:
private void addRecord(String key_, String value_)
{
//DBBinding myDBBinding=new DBBinding(key_, value_);//constructor not defined error
//DBBinding myDBBinding(key_,value_);
//DataBase.DBBinding myDBBinding=new DataBase.DBBinding(key_, value_);//constructor not defined error
}
这是 DBBinding 代码,后面是 DBrecord 代码。
package DataBase;
public class DBBinding {
private String key;
private String value;
public void DBBinding(String key_, String value_)
{
String key =new String(key_);
String value=new String(value_);
}
//public String toString()
//{return key+": "+value;}
}
和
package DataBase;
//package DataBase.*;
import DataBase.*;//did not help ... ?
public class DBrecord {
boolean select;
String key;
//need some type of collection to keep bindings.
public void DBrecord()
{
DBrecord myRecord=new DBrecord();
select=false;
}
private void addRecord(String key_, String value_)
{
//DBBinding myDBBinding=new DBBinding(key_, value_);//constructor not defined error
//DBBinding myDBBinding(key_,value_);
//DataBase.DBBinding myDBBinding=new DataBase.DBBinding(key_, value_);//constructor not defined error
}
public String toString()
{
//out put key first then all values in collection/group/record. use correct formatting.
}
}