所以即時嘗試在我的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