Auf Thema antworten

Hallo :),

und zwar wuerde ich gerne wissen wie man aus einem array, einzelne Zahlen die man eingefuegt hat in einen if satz einfuegt.

Dazu muss ich noch sagen, das ich eine liste mit strings gemacht habe und darin per fare zahlen eingefuegt habe.

Das ist meine Liste:

[code=Java]

public class PostageCalculator extends javax.swing.JFrame {


  String [] destinations={"Australia - Capital City", "Australia - Country", "Overseas"};

    public PostageCalculator() {

        initComponents();

        int destinationNo = 0;

while (destinationNo < destinations.length)

{

    cbxDestination.addItem(destinations[destinationNo]);

     destinationNo = destinationNo + 1;

}

[/code]

und dass sind die fare zahlen, mit absicht 3 nullen da ich zusaetzliche kosten mit den if saetzten einfuegen moechte.

 [code=Java]

int []fares={0,0,0};

    int destinationNo= cbxDestination.getSelectedIndex();

    String destination= destinations[destinationNo];

    int fare =fares [destinationNo];

[/code]

Also jetzt will ich einzelne zahlen im array in einen if Satz packen um  plus 10 zu addieren

Zum Beispiel:

[code=Java]

 if    ( destinationNo = fares[0] )

{

postage = 10;

}

[/code]


 fares[0] ist geraten!


ich komme einfach nicht drauf :D



Danke im Vorraus



Oben