Untitled
unknown
plain_text
3 years ago
8.7 kB
8
Indexable
public void AddRecord(ArrayList<MaltesePlayers> F)
{
String[] nationalities = {"Maltese", "Foreign"};
JComboBox<String> comboBox = new JComboBox<>(nationalities);
int option = JOptionPane.showOptionDialog(null, comboBox, "Select player nationality", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{"OK", "Exit"}, "OK");
if (option == JOptionPane.OK_OPTION) {
String nationality = (String) comboBox.getSelectedItem();
if (nationality == "Maltese")
{
MaltesePlayers mc = new MaltesePlayers();
JComboBox<Integer> comboBox2 = new JComboBox<>();
for (int i = 7; i < 18; i++) {
comboBox2.addItem(i);
}
int option1 = JOptionPane.showOptionDialog(null, comboBox2, "Select player age", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{"OK", "Exit"}, "OK");
if (option1 == JOptionPane.OK_OPTION) {
int age = (int) comboBox2.getSelectedItem();
switch(age) {
case 6: int six = 8;
mc.setDivision(six); break;
case 7: int seven = 8;
mc.setDivision(seven); break;
case 8: int eight = 10;
mc.setDivision(eight); break;
case 9: int nine = 10;
mc.setDivision(nine); break;
case 10: int ten = 12;
mc.setDivision(ten); break;
case 11: int eleven = 12;
mc.setDivision(eleven); break;
case 12: int twelve = 4;
mc.setDivision(twelve); break;
case 13: int thirteen = 14;
mc.setDivision(thirteen); break;
case 14: int fourteen = 16;
mc.setDivision(fourteen); break;
case 15: int fifteen = 16;
mc.setDivision(fifteen); break;
case 16: int sixteen = 18;
mc.setDivision(sixteen); break;
case 17: int seventeen = 18;
mc.setDivision(seventeen); break;
default: break;
}
String ID = JOptionPane.showInputDialog("Please enter ID");
mc.setID(ID);
String Surname = JOptionPane.showInputDialog("Please enter Surname");
mc.setSurname(Surname);
String Name = JOptionPane.showInputDialog("Please enter Name");
mc.setName(Name);
String Locality = JOptionPane.showInputDialog("Please enter Locality");
mc.setLocality(Locality);
String PN = JOptionPane.showInputDialog("Please enter Player Number");
int PlayerNo = Integer.parseInt(PN);
mc.setPlayerNo(PlayerNo);
String H = JOptionPane.showInputDialog("Please enter Height in cm");
int Height = Integer.parseInt(H);
mc.setHeight(Height);
String G = JOptionPane.showInputDialog("Please enter no. of Goals Scored");
int Goals = Integer.parseInt(G);
mc.setGoals(Goals);
String A = JOptionPane.showInputDialog("Please enter no. of Assists Made");
int Assists = Integer.parseInt(A);
mc.setAssists(Assists);
F.add(mc);
}
else {
System.out.println("Exiting to Main Menu");
}
}
else
{
System.out.println("Exiting to Main Menu");
}
}
else
{
ForeignPlayers fc = new ForeignPlayers();
JComboBox<Integer> comboBox2 = new JComboBox<>();
for (int i = 7; i < 18; i++) {
comboBox2.addItem(i);
}
int option1 = JOptionPane.showOptionDialog(null, comboBox2, "Select player age", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{"OK", "Exit"}, "OK");
if (option1 == JOptionPane.OK_OPTION) {
int age = (int) comboBox2.getSelectedItem();
switch(age) {
case 7: int seven = 8;
fc.setDivision(seven); break;
case 8: int eight = 10;
fc.setDivision(eight); break;
case 9: int nine = 10;
fc.setDivision(nine); break;
case 10: int ten = 12;
fc.setDivision(ten); break;
case 11: int eleven = 12;
fc.setDivision(eleven); break;
case 12: int twelve = 4;
fc.setDivision(twelve); break;
case 13: int thirteen = 14;
fc.setDivision(thirteen); break;
case 14: int fourteen = 16;
fc.setDivision(fourteen); break;
case 15: int fifteen = 16;
fc.setDivision(fifteen); break;
case 16: int sixteen = 18;
fc.setDivision(sixteen); break;
case 17: int seventeen = 18;
fc.setDivision(seventeen); break;
default: break;
}
String ID = JOptionPane.showInputDialog("Please enter Passport No.");
fc.setID(ID);
String Surname = JOptionPane.showInputDialog("Please enter Surname");
fc.setSurname(Surname);
String Name = JOptionPane.showInputDialog("Please enter Name");
fc.setName(Name);
String Locality = JOptionPane.showInputDialog("Please enter Locality");
fc.setLocality(Locality);
String PN = JOptionPane.showInputDialog("Please enter Player Number");
int PlayerNo = Integer.parseInt(PN);
fc.setPlayerNo(PlayerNo);
String H = JOptionPane.showInputDialog("Please enter Height in cm");
int Height = Integer.parseInt(H);
fc.setHeight(Height);
String G = JOptionPane.showInputDialog("Please enter no. of Goals Scored");
int Goals = Integer.parseInt(G);
fc.setGoals(Goals);
String A = JOptionPane.showInputDialog("Please enter no. of Assists Made");
int Assists = Integer.parseInt(A);
fc.setAssists(Assists);
F.add(fc);
}
else {
System.out.println("Exiting to Main Menu");
}
}
}Editor is loading...