lundi 4 novembre 2019

Setter - Checking the value

I am supposed to check the value and if its not the value, I do not update the value. And if the input is valid then i return it. I am stuck here now. Can someone help me. I wrote some code but it doesnt work.

public class Student {
    private int studentId;
    private String name;
    private double grade;
    private double multiplier;


public double getMultiplier() {
    return multiplier;
}

/**
 * The setter for the multiplier must check that the value is either 1.08 *
 * 1.06 or 1.08 or 1.06
 * 
 * If not, then do not update the value
 * 
 * @param multiplier
 * @return if the input was valid
 */
public boolean setMultiplier(double multiplier) {


    if( multiplier == 1.08 * 1.06 || multiplier == 1.08 || multiplier == 1.06 ) {

    }
    return multiplier;
}

Aucun commentaire:

Enregistrer un commentaire