我很难弄清楚应该放置ers++
或ers+=1
的位置。我已经尝试过for循环和do-while,它工作并达到了3的限制,但它也应该让用户再次输入并再次检查输入。
if (ers < 3) {
if (a.equals(SignupPage.ee) && b.equals(SignupPage.dd) && !(a.isEmpty()) && !(b.isEmpty())) {
System.out.println(a+" "+b);
tf = true;
JOptionPane.showMessageDialog(null, "Welcome!", "Payment Portal", JOptionPane.INFORMATION_MESSAGE);
ElectricityPage ep = new ElectricityPage();
ep.setVisible(true);
} else if (a.equals("Admin") && b.equals("javaness") && !(a.isEmpty()) && !(b.isEmpty())) {
SignupPage.aa = Admin.Fname[0];
SignupPage.aa = Admin.Lname[0];
ers+=1;
ElectricityPage ep = new ElectricityPage();
ep.setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "something is wrong", "Payment Portal", JOptionPane.ERROR_MESSAGE);
//ers=ers+1;
}
System.out.println(ers);
}