

/**
 * Created by shimin on 9/24/2014.
 */
public class Controller {

    private int temperature;
    private int lighting;
    private int pressure;
    private int humidity;
    private int sound;
    private int sensorID;

    public int getTemperature(){ return temperature;}

    public int getLighting(){ return lighting;}

    public int getPressure(){return pressure;}

    public int getHumidity(){return humidity;}

    public int getSound(){return sound;}

    public int getSensorID(){return sensorID;}

}

@@ -1,8 +1,122 @@
+import com.mysql.jdbc.Connection;%0Aimport db.DBConnector;%0A%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;
 %0A%0A/**%0A *
@@ -176,16 +176,36 @@
 troller 
+extends DBConnector 
 %7B%0A%0A    p
@@ -211,19 +211,22 @@
 private 
-int
+double
  tempera
@@ -229,16 +229,22 @@
 perature
+ = 0.0
 ;%0A    pr
@@ -373,36 +373,704 @@
     
-public int getTemperature()%7B
+/*%0A     * A database connection is available through the inherited field 'connection'.%0A     */%0A%0A    public double getTemperature()%7B%0A        String query =  %22SELECT Value FROM TemperatureSample JOIN (%22 +%0A                        %22SELECT MAX(Date) as MaxDate FROM TemperatureSample AS T1%22 +%0A                        %22) AS T2 WHERE Date = MaxDate%22;%0A%0A        try %7B%0A            preparedStatement = connection.prepareStatement(query);%0A            preparedStatement.execute();%0A            ResultSet results = preparedStatement.getResultSet();%0A            results.next();%0A            temperature = results.getDouble(1);%0A        %7D catch (SQLException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A       
  ret
@@ -1081,24 +1081,29 @@
 temperature;
+%0A    
 %7D%0A%0A    publi
@@ -1328,10 +1328,179 @@
 orID;%7D%0A%0A
+    public static void main(String%5B%5D args)%7B%0A        Controller ctrl = new Controller();%0A        ctrl.connect();%0A        System.out.println(ctrl.getTemperature());%0A    %7D%0A
 %7D%0A

Make the getTemperature() function barely work