예제 #1
0
  public void startConversation() {

    String fullName = JOptionPane.showInputDialog("Enter full name:");
    String lastName = nameService.extractLastName(fullName);
    String msg = "Your last name is: " + lastName;
    JOptionPane.showMessageDialog(null, msg);
  }
예제 #2
0
  public void startConversation() {
    try {
      String fullName = JOptionPane.showInputDialog("Enter full name:");
      String lastName = "";
      lastName = nameService.extractLastName(fullName);

      String msg = "Your last name is: " + lastName;
      JOptionPane.showMessageDialog(null, msg);
    } catch (NullPointerException npe) {
      JOptionPane.showMessageDialog(null, npe);
    }
  }
예제 #3
0
  /** Gets the user's full name and outputs the last name */
  public void startConversation() {

    String fullName = JOptionPane.showInputDialog("Enter full name:");
    String lastName = "";

    try {
      lastName = nameService.extractLastName(fullName);
    } catch (NullPointerException npe) {
      System.out.println(npe.getMessage());
    } catch (EmptyStringException ese) {
      System.out.println(ese.getMSG());
    } catch (IllegalNameException ine) {
      System.out.println(ine.getMSG());
    }

    String msg = "Your last name is: " + lastName;
    JOptionPane.showMessageDialog(null, msg);
  }