Ok folks, sorry to keep asking questions in this forum, but i am just tidying up the nitty gritty issues in my program and i encountered many problems. :cry:
my issue here is i can allow user to key in seat number for this booking program. For example, if there are 2 person, then they have to key in 1-2. Different set of numbers belong to different type of seats. 1-5 is business class, 6-20 is economy class.
validation is already done for those keying in only one person (e.g: seat no 1). Now I want to validate the seat numbers that they keyed in (e.g: 1-2, when they select economy class show return an error) belongs to the correct type of seat.
Below is my code:
String validateSeatType() {
String seat = jTextSeatNo.getText();
String[] seatNo = seat.split("-");
// this is where the error occurs and I just can't figure out how to solve it
for (int i = 0; i < seatNo.length; i++) {
Integer.parseInt(seatNo[i]);
if (jRBSeatBiz.isSelected() && (seatNo < 1 || seatNo > 6)) {
return "- Business class seat no should be 1- 6\n";
}
else if (jRBSeatEcon.isSelected() && (seatNo < 7 || seatNo > 20)) {
return "- Economy class seat no should be 7-20\n";
}
return ""; // no error
}
}
Any help is greatly appreciated. :o