jeudi 8 novembre 2018

only last IF statement being executed

When I run my code on my phone the APK installs and opens, but when i type in the two parameters, the only option returned is the final if statement. Even if it is false and other statements are true, it still executes. This is the MainActivity.java file.

    float crazy;
float hotness;
static final String NOGOZONE = "ExampleText";
static final String DANGERZONE = "ExampleText";
static final String FUNZONE = "ExampleText" ;
static final String UNICORN = "ExampleText" ;
static final String TRANNY = "ExampleText" ;
static final String LESSTHAN4 = "ExampleText" ;
static final String WIFEZONE = "ExampleText" ;
static final String DATEZONE = "ExampleText" ;

public void main(View view)
{
    String herZone = test(hotness, crazy);
    ((TextView)findViewById(R.id.output)).setText(herZone);
}

static String test(float hotness, float crazy)
{
    String herZone = DANGERZONE;
    if ( hotness < 5 )
    {
        herZone = NOGOZONE;
    }
    if ( hotness >= 5 && crazy <= 5 )
    {
        herZone = FUNZONE;
    }
    if ( hotness >= 5 && hotness < 7 && crazy > 5 && crazy <= 7)
    {
        herZone = DANGERZONE;
    }
    if ( hotness > 7 && crazy > 8 )
    {
        herZone = DANGERZONE;
    }
    if ( hotness >= 7 && hotness < 8 && crazy > 5 && crazy <= 8)
    {
        herZone = FUNZONE;
    }
    if ( hotness < 7 && crazy > 7 )
    {
        herZone = DANGERZONE;
    }
    if ( hotness >= 8 && crazy >= 7 )
    {
        herZone = DATEZONE;
    }
    if ( hotness >= 8 && crazy <= 7 )
    {
        herZone = WIFEZONE;
    }
    if ( hotness >= 8 && crazy <= 5 )
    {
        herZone = UNICORN;
    }
    if ( hotness >= 8 && crazy <= 4 )
    {
        herZone = TRANNY;
    }
    if ( crazy < 4 )
    {
        herZone = LESSTHAN4;
    }
    return herZone;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

This Buttons xml onClick code is android:onClick="main". Does anyone know how to fix this? Am I making a stupid mistake? thanks in advance :) <3

Aucun commentaire:

Enregistrer un commentaire