Hello, i need help with my code.
I'm trying to compile a method for making phone calls but i get an error that i'm not sure why. (BlueJ)
Here is the code connected with this method:
public int getPhoneNumber() { int phoneNumber = Integer.parseInt(phoneNoField.getText()); if (phoneNumber == -1) { JOptionPane.showMessageDialog(frame, "Please use a positive number", "Attention", JOptionPane.WARNING_MESSAGE); } return phoneNumber; } public int getDuration() { int theDuration = Integer.parseInt(durationField.getText()); if (theDuration == -1) { JOptionPane.showMessageDialog(frame, "Please enter a positive number", "Attention", JOptionPane.WARNING_MESSAGE); } return theDuration; } public int getDisplayNum() { int getDisplayNum = -1; try { getDisplayNum = Integer.parseInt(displayNoField.getText())-1; if(getDisplayNum < 0){ JOptionPane.showMessageDialog(frame, "Please enter a number greater than 0", "Attention", JOptionPane.WARNING_MESSAGE); } } catch(NumberFormatException e){ JOptionPane.showMessageDialog(frame, "Please enter an integer", "Attention", JOptionPane.WARNING_MESSAGE); } return getDisplayNum; } public void phoneCall() { Gadget mobPhone = Devices.get(getDisplayNum()); if (getDisplayNum() != -1 && mobPhone instanceof Phone) { Phone phone = (Phone) Devices.get(getDisplayNum()); phone.phoneCall(getDisplayNum(), getDuration()); } else { JOptionPane.showMessageDialog(frame, "This isn't a Mobile Phone", "Attention", JOptionPane.WARNING_MESSAGE); } }
Please let me know if you need more info
Thank you