I am trying to basically use the methods as functions and then call them in main but I cant figure it out. I thought it could be done like this but maybe I am just confusing my php&mysql class with Java. At the bottom of my code, there is a comment with what exactly I was trying to accomplish. Sorry if I am not using proper terminology but I am not very familiar with java.

import javax.swing.JOptionPane;
public class DouglasPassword {
   public String pword, pwordVerify;
   public String validatePword(String pword)
   {
      pword = JOptionPane.showInputDialog(null, "Enter Password: ", "Create Password", JOptionPane.QUESTION_MESSAGE);
      if (pword.length() > 5 && pword.length() < 11) {
        for (int j = 0;j < pword.length();j++) {
	if (Character.isDigit(pword.charAt(j))) {
		                                }
	                                       }
      JOptionPane.showMessageDialog(null, "Correct Password!", "Correct Password!", JOptionPane.INFORMATION_MESSAGE);
      }
      else 
      JOptionPane.showMessageDialog(null, "Incorrect Password! Please Try Again.", "Incorrect Password!", JOptionPane.ERROR_MESSAGE);
     return pword;
   }
   public String verifyPword(String pword, String pwordVerify, Boolean pass){

      pwordVerify = JOptionPane.showInputDialog(null, "Confirm Password: ", "Confirm Password", JOptionPane.QUESTION_MESSAGE);
       if(pword.equals(pwordVerify)){
         JOptionPane.showMessageDialog(null, "Correct Password!", "Correct Password!", JOptionPane.INFORMATION_MESSAGE);
       }
       else {
         JOptionPane.showMessageDialog(null, "Incorrect Password! Please Try Again.", "Incorrect Password!", JOptionPane.ERROR_MESSAGE);
       }
       return pwordVerify;
   }
      public static void main(String[] args)
    {   
          //I wanted to have the code here be something like while(x=false) execute validatePword until x=true
          //Then do it verifyPword until y=true.
    }

}

Edited 6 Years Ago by acdougla17: n/a

It seems you are from a Structured Programming background so you need to keep in mind that your main method is static and so can access only static methods and static fields of other classes (or even same class)directly.
Remember Java is object oriented so to invoke your methods as they are now, you will need to first create an object of your class and then invoke the methods on the object, kind of like:-

DouglasPassword passwd = new DouglasPassword();
passwd.validatePWword(word);
.
.
.

Otherwise in case you just want to proceed the way of the Structured Methodology just mark all your methods and fields as static, your code "should" work.
here is a good tutorial if you want to learn more about Object Oriented Programming.

Edited 6 Years Ago by stephen84s: n/a

This article has been dead for over six months. Start a new discussion instead.