Final Project Engg 233

Hey everyone, i have been struggling in this course. We have to make a digital dashboard of a car. Any help would be appreciated.

Capture

Requirements for this class:

Class SensorDataProvider
This class has the following member variables:

  • filePath to store the path of the selected sensor data file
  • dataTable of type Table to load the data in the csv input file
  • currentIndex representing the data row index that needs to be processed

This class has the following member functions:

  • Initialize(): This function is called at the beginning of the program. It reads the
    whole input csv file and loads it into dataTable.
  • readNext(). This function is called in the main loop of the program (draw). Each
    call advances to the next line by incrementing currentIndex. In order to make
    sure that the program does not crashes because of null reference, there should
    be a cap on incrementing currentIndex.
  • readRPM(), readFuelLevel(), readRatio(), readX() and readY() functions to read
    the current row of the file.

My code so far(Probably all wrong) :

class SensorDataProvider {
  String filePath = "car_status_Truck_F150.csv";
  Table dataTable = loadTable(filePath, "header");
  TableRow row;
  int currentIndex = 0;

  void Initialize() {

    for (TableRow row : dataTable.rows()) {

      int time = row.getInt("Time");
      float gearratio = row.getFloat("Gear Ratio");
      float fuellevel = row.getFloat("Fuel Level (liter)");
      int RPM = row.getInt("RPM");
      float X = row.getFloat("X");
      float Y = row.getFloat("Y");
    }
  }
  int readNext() {
    for (TableRow row : dataTable.rows()) {
      currentIndex ++;
    }
    return currentIndex;
  }

  int readRPM() {
    row = dataTable.getRow(currentIndex);
    return int("RPM");
  }
  float readFuelLevel(){
    row = dataTable.getRow(currentIndex);
    return int("Fuel Level (liter)");
  }
  float readRatio(){
    row = dataTable.getRow(currentIndex);
    return int("Gear Ratio");
  }
  
  float readX(){
    row = dataTable.getRow(currentIndex);
    return int("X");
  }
  float readY(){
    row = dataTable.getRow(currentIndex);
    return int("Y");
  }
}

Hi,

What is your problem ? Where is it that you are stuck ? Can you be a bit more precise in what you are asking ?

I feel like my class and the member functions are wrong, which is the area i need help in.

Well, it is quite vague.
Is it doing what you are expecting it to do or not ? If not what is it doing wrong ?

Also go check that link, that might help you to narrow down the problem: Guidelines—Tips on Asking Questions

i dont really know what to do, rip me.