所以即时尝试在我的simpleDB数据库中实现加法运算符。我做了大部分工作,但我不知道如何添加2个部分。所以这将用于查询数据库,我想能够添加左侧和右侧。什么java方法可以用来做到这一点?因为在simpleDB中没有添加运算符。Java运算符是如何工作的?
这是我是如何实现的<运营商像现在我有
Constant lhsval = lhs.evaluate(s);
Constant rhsval = rhs.evaluate(s);
if (operator.equals("+")) {
// return ;
}
我有左侧和右侧 所以当查询看到的+号
if (operator.equals("<") && lhsval.compareTo(rhsval) < 0) {
return true;
}
,它会添加并返回答案。但我不知道如何。当我实现了少于运算符时,我使用了comprateTo方法,并且当我使用等于运算符时使用了equals方法。我不知道我可以用加法operator.btw这是用java
不断类
package simpledb.query;
/**
* The interface that denotes values stored in the database.
* @author Edward Sciore
*/
public interface Constant extends Comparable<Constant> {
/**
* Returns the Java object corresponding to this constant.
* @return the Java value of the constant
*/
public Object asJavaVal();
}
不是很清楚,你想串联,将被发送到一个数据库中获取记录查询的各个组成部分? –
你有没有试过'lhsval.concat(rhsval)' – Billydan
无法使用concat,它没有实现。多数民众赞成什么使这个硬大声笑 – henryzo