dimanche 3 mai 2015

How can I change code this to a switch statement?

I'm pretty new to java, and I was wondering if it was possible to change this code to be a switch statement.

    public double getBagelCost()
    {
        double bagelCost = 0.0;

        if (whiteBagel.isSelected())
            bagelCost = WHITE_BAGEL;
        else if (wheatBagel.isSelected())
            bagelCost = WHEAT_BAGEL;
        else
            bagelCost = CINNAMON_CRUNCH_BAGEL;

        return bagelCost;
    }

Aucun commentaire:

Enregistrer un commentaire