public void add() {
// declaring and initializing the blank for if statement
String blank = "";
// getting the informations from the imputs
firsts = first.getText();
lasts = last.getText();
s1 = w1.getText();
s2 = w2.getText();
s3 = w3.getText();
s4 = w4.getText();
// equalling the same variables so it will help to make if statement work properly
fs = firsts;
ls = lasts;
ss1 = s1;
ss2 = s2;
ss3 = s3;
ss4 = s4;
iw1 = Integer.parseInt(s1); // converting from string to integer for week 1
iw2 = Integer.parseInt(s2); // converting from string to integer for week 2
iw3 = Integer.parseInt(s3); // converting from string to integer for week 3
iw4 = Integer.parseInt(s4); // coverting from string to integer for week 4
if (fs.equals(blank) || ls.equals(blank) || ss1.equals(blank) || ss2.equals(blank) || ss3.equals(blank) || ss4.equals(blank)) {
JOptionPane.showMessageDialog(null, "You have not type in one or more blank fields. Please try again.");// display the mesage
} else if (iw1 < 0 || iw2 < 0 || iw3 < 0 || iw4 < 0) {
JOptionPane.showMessageDialog(null, "You typed the point(s) in negative value(s). Please try again by entering a positive value(s).");// display the mesage
} // adding the new passenger info into the data
else {
firstn.add(firsts);
lastn.add(lasts);
we1.add(iw1);
we2.add(iw2);
we3.add(iw3);
we4.add(iw4);
}
}
I am getting a crash on the program when I hit add button when I left some field blanks and putting - values for week 1, 2, 3, and 4. Can you help me please. aaaaaaaaaysdioyudewdwdewywdwey8wed9wyde9wdy8e89yw9dewy8d9dweyd8e9wdy8e8dy8e98wdy89e8yd8y9ey8dy8ey8yd8y8e8d8yywydy8y8dy8yedeyd88yed8ye8d8eyd8de8edwy8ey0edwyewwy80w8yey8dy8edydyedshuchiudhucudchdhcudgiyf989fy8e8dyd9ydfchudhchudhuucduhhudhhdudud98e8de8wy8dywyy8eyy8eyyeyfe9y77fhcdc8jc8jcj8c8ew0e0we88fufh
Aucun commentaire:
Enregistrer un commentaire