Advertisement
simeonvarbanov

Assignment

Sep 23rd, 2012
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include "NativeMethod.h"
  2. #include "legacy.h"
  3. #include <stdio.h>
  4. JNIEXPORT jint JNICALL Java_NativeMethod_calculateGreenTax(JNIEnv *env,
  5.         jclass cls, jobject car) {
  6.     jclass Car = (*env)->GetObjectClass(env, car);
  7.  
  8.     jfieldID id_category = (*env)->GetFieldID(env, Car, "category", "I");
  9.     jint category = (*env)->GetIntField(env, car, id_category);
  10.  
  11.     jfieldID id_km = (*env)->GetFieldID(env, Car, "km", "D");
  12.     jdouble km = (*env)->GetDoubleField(env, car, id_km);
  13.  
  14. //  jmethodID idCategory = (*env)->GetMethodID (env, Car, "getCategory", "()I");
  15. //    int category = (*env)->CallIntMethod (env, car, idCategory);
  16. //
  17. //    jmethodID idKm = (*env)->GetMethodID (env, Car, "getKm", "()D");
  18. //  double km = (*env)->CallDoubleMethod (env, car, idKm);
  19.  
  20.     return calculate(category, km);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement