mardi 26 mars 2019

How to invoke a function in an if statement that will write to a database when the weight changes

I am attempting to invoke a function(as seen in the pseudo code below) that will count 50 or so readings of a carton of 6 eggs as it calibrates the weight on my USB DYMO M5 scale, of the carton and once one egg is removed it will write one egg to a shopping database table and remove one egg from the 6 in a fridge database. I was wondering what would be the most efficient way of going about this would be? Any feedback would be appreciated.

int count = 0; int oldweight=0;

    //oldweight = weight;
    if (oldweight == weight) {
        // do nothing
    } else {
        System.out.println("Weight Changes");
        /* write DB


        //if (weight < oldweight){
        //then something was taken off
         * 
         * remove equivalent amount of eggs from db.fridge.

        //if(db.frdige == 0 eggs){
            //order eggs
        }

        if(weight > oldweight){
            somebody put eggs in the fridge. 
        }
        *
        *
        *


    }*/
        oldweight=weight;
    }

    if (weight != oldweight) {
        while (count <= 5000) {
            count++;
        }
        while (count < 5)
            weight = count++;

Aucun commentaire:

Enregistrer un commentaire