Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: UML diagram

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default UML diagram

    I need to make a UML diagram for my java classes. I know what they are and how to generally make them, but I don't know how to make one for one of my java classes. I was wondering if someone could help me with my problem. Here is the code for the java class that doesn't have a UML diagram:
    /**
    * This class is uses the PasswordChecker class to create an interface that allows users to enter passwords, and if they meet the criteria, they
    * are stored in a password file.
    * @author	*****
    * @since	2012-08-25
    */
     
    // This imports all java Input/Output methods so that they can be used by these class methods
    import java.io.*;
     
    // This allows the PasswordCheckerTester class to use the PasswordChecker class's constructors and methods.
    import tools.*;
     
    class PasswordCheckerMain {
     
    	// If there is a problem with the user's input, then an IOException will be thrown
    	public static void main(String args[]) throws IOException {
     
    		// This object is used to read input from the user
    		BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
     
    		// This is the file that the valid passwords will be output to, as well as the file containing the passwords that the PasswordChecker's
    		// password will be compared to.
    		String fileName = "passwords.txt";
     
    		// This creates a File object using the String contained in fileName.  The File object is stored in the variable fileCheck 
    		File fileCheck = new File(fileName);
     
    		// This variable will be used as a condition for several while loops.  Basically, it is used to determine whether the user has entered
    		// valid input.
    		boolean acceptableAnswer;
     
    		// This if statement checks to see if the password file already exists
    		if (fileCheck.exists()) { 
     
    				// This prints out a message, and asks the user to input a response.
    				System.out.print("\n" + "There is an existing password text file." + "\n" + "Would you like to view its contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    				// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    				acceptableAnswer = false;
     
    				// This while loop will repeat until the user enters a valid response to the previous request
    				while(!acceptableAnswer) {
     
    					// This reads in the user input and stores it in the variable answer
    					String answer = userInput.readLine();
     
    					// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    					if (answer.equalsIgnoreCase("Y")) {
     
    						// This opens the file fileName so that it can be read
    						FileInputStream fstream = new FileInputStream(fileName);
     
    						// These next two declarations make it possible to actually read the given file and get its contents.
    						DataInputStream in = new DataInputStream(fstream);
     
    						BufferedReader bufferRead = new BufferedReader(new InputStreamReader(in));
     
    						// This creates the variable stringLine to be used in the upcoming while loop
    						String stringLine;
     
    						// This while loop reads the contents of the file fileName until it reaches the end.  Whenever it reads a line, it stores
    						// the line in the variable stringLine (overwritting what was previously stored)
    						while ((stringLine = bufferRead.readLine()) != null) {
     
    							// This prints out what is contained in the variable stringLine
    							System.out.println(stringLine);
    						}	
     
    						// This closes the file fileName
    						in.close();
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    						acceptableAnswer = true;
    					}
     
    					// This if statement checks to see if the user's input was equal to "N", ignoring the case of the input
    					else if (answer.equalsIgnoreCase("N")) {
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    						acceptableAnswer = true;
    					}
     
    					else {
     
    						// This prints out a message, and asks the user to input a response.
    						System.out.print("Invalid input." + "\n" + "Would you like to view the file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    					}
    				}
     
    				// This prints out a message, and asks the user to input a response.
    				System.out.print("\n" + "Would you like to erase the file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    				// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    				acceptableAnswer = false;
     
    				// This while loop will repeat until the user enters a valid response to the previous request
    				while(!acceptableAnswer) {
     
    					// This reads in the user input and stores it in the variable answer
    					String answer = userInput.readLine();
     
    					// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    					if (answer.equalsIgnoreCase("Y")) {
     
    						// This creates a File object using the String fileName.  The File object is stored in the variable yourFile
    						File yourFile = new File(fileName);
     
    						// This deletes the file used to construct the File object yourFile
    						yourFile.delete();
     
    						// This creates a File object using the String fileName. The File object is stored in the variable yourNewFile
    						File yourNewFile = new File(fileName);
     
    						// This creates an empty file in the same directory as the one that this program is stored.  The file's name is the 
    						// String in fileName
    						yourNewFile.createNewFile();
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    						acceptableAnswer = true;
    					}
     
    					// This if statement checks to see if the user's input was equal to "N", ignoring the case of the input
    					else if (answer.equalsIgnoreCase("N")) {
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    						acceptableAnswer = true;
    					}
     
    					else {
     
    						// This prints out a message, and asks the user to input a response.
    						System.out.print("Invalid input." + "\n" + "Would you like to erase the file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    					}
    				}
     
    				// This prints out a message
    				System.out.println("\n" + "This program will require you to enter a password that meets the following" + "\n" + "criteria:" + "\n");
     
    				// This prints out a message
    				System.out.println("The password must have at least 8 characters, but no more than 10 characters.");
     
    				// This prints out a message
    				System.out.println("The password must have at least one capital letter.");
     
    				// This prints out a message
    				System.out.println("The password must have at least one special character (ex. !, @, #, etc.)");
     
    				// This prints out a message
    				System.out.println("The password cannot be one that is already stored in the password file." + "\n");
     
    				// This prints out a message, and asks the user to input a response.
    				System.out.print("Please enter your password: ");
     
    				// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    				boolean done = false;
     
    				// This while loop will repeat until the user is done with this program
    				while (!done) {
     
    					// This reads in the user input and stores it in the variable userPassword
    					String userPassword = userInput.readLine();
     
    					// This creates a PasswordChecker object using the String contained in userPassword.  The PasswordChecker object is stored
    					// in the variable checker
    					PasswordChecker checker = new PasswordChecker(userPassword);
     
    					// This checks to see if the checkLength() method of the PasswordChecker class will return true
    					if (checker.checkLength()) {
     
    						// This checks to see if the checkCapital() method of the PasswordChecker class will return true
    						if (checker.checkCapital()) {
     
    							// This checks to see if the checkSpecial() method of the PasswordChecker class will return true
    							if (checker.checkSpecial()) {
     
    								// This checks to see if the checkNoDuplicate() method of the PasswordChecker class will return true
    								if (checker.checkNoDuplicate(fileName)) {
     
    									// This prints out a message
    									System.out.println("Valid password.");
     
    									// It is possible that an exception will occur when the password file is opened for output, hence why a
    									// try/catch block is used
    									try {
     
    										// This opens the file fileName for output
    										FileWriter fstream = new FileWriter(fileName, true);
     
    										// This object is what is used to output data tot he file fileName
    										BufferedWriter out = new BufferedWriter(fstream);
     
    										// This writes whatever is in the first set of parentheses (in this case, it is checker.getPassword()) to
    										// the file that was opend for output (in this case, fileName)
    										out.write(checker.getPassword());
     
    										// This writes whatever is in the first set of parentheses (in this case, a newline character) to
    										// the file that was opend for output (in this case, fileName)
    										out.write("\n");
     
    										// This closes the file
    										out.close();
     
    										// This prints out a message, and asks the user to input a response.
    										System.out.print("\n" + "Would you like to view the password file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    										// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    										acceptableAnswer = false;
     
    										// This while loop will repeat until the user enters a valid response to the previous request
    										while(!acceptableAnswer) {
     
    											// This reads in the user input and stores it in the variable answer
    											String answer = userInput.readLine();
     
    											// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    											if (answer.equalsIgnoreCase("Y")) {
     
    												// This opens the file fileName so that it can be read
    												FileInputStream fstream2 = new FileInputStream(fileName);
     
    												// These next two declarations make it possible to actually read the given file and get its contents.
    												DataInputStream in2 = new DataInputStream(fstream2);
     
    												BufferedReader bufferRead2 = new BufferedReader(new InputStreamReader(in2));
     
    												// This creates the variable stringLine to be used in the upcoming while loop
    												String stringLine2;
     
    												// This while loop reads the contents of the file fileName until it reaches the end.  Whenever it reads a line, it stores
    												// the line in the variable stringLine (overwritting what was previously stored)
    												while ((stringLine2 = bufferRead2.readLine()) != null) {
     
    													// This prints out what is stored in variable stringLine2
    													System.out.println(stringLine2);
    												}	
     
    												// This closes the file fileName
    												in2.close();
     
    												// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    												acceptableAnswer = true;
    											}
     
    											// This if statement checks to see if the user's input was equal to "N", ignoring the case of the input
    											else if (answer.equalsIgnoreCase("N")) {
     
    												// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    												acceptableAnswer = true;
    											}
     
    											else {
     
    												// This prints out a message, and asks the user to input a response.
    												System.out.print("Invalid input." + "\n" + "Would you like to view the password file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    											}
    										}
     
    									}
     
    									// If an exception does occur when opening fileName for output, this catch block will execute, print out a 
    									// message, and the program will terminate
    									catch (Exception error){
     
    										System.err.println("Error: " + error.getMessage());
    									}
    								}
     
    								else {
     
    									// This prints out a message
    									System.out.println("This password is already in the password file.");
    								}
    							}
     
    							else {
     
    								// This prints out a message
    								System.out.println("Password does not contain a special character.");
    							}
    						}
     
    						else {
     
    							// This prints out a message
    							System.out.println("Password does not contain a capital letter.");
    						}
    					}
     
    					else {
     
    						// This prints out a message
    						System.out.println("Invalid password length.");
    					}
     
    					// This prints out a message, and asks the user to input a response.
    					System.out.print("\n" + "Do you want to enter another password" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    					// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    					acceptableAnswer = false;
     
    					// This while loop will repeat until the user enters a valid response to the previous request
    					while(!acceptableAnswer) {
     
    						// This reads in the user input and stores it in the variable answer
    						String answer = userInput.readLine();
     
    						// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    						if (answer.equalsIgnoreCase("Y")) {
     
    							// This assigns boolean true to the variable acceptableAnswer, which will make the inner while loop will stop executing
    							acceptableAnswer = true;
     
    							// This prints out a message
    							System.out.println("\n" + "The password must have at least 8 characters, but no more than 10 characters.");
     
    							// This prints out a message
    							System.out.println("The password must have at least one capital letter.");
     
    							// This prints out a message
    							System.out.println("The password must have at least one special character (ex. !, @, #, etc.)");
     
    							// This prints out a message
    							System.out.println("The password cannot be one that is already stored in the password file." + "\n");
     
    							// This prints out a message, and asks the user to input a response.
    							System.out.print("Please enter your password: ");
    						}	
     
    						// This if statement checks to see if the user's input was equal to "N", ignoring the case of the input
    						else if (answer.equalsIgnoreCase("N")) {
     
    							// This assigns boolean true to the variable acceptableAnswer, which will make the inner while loop will stop executing
    							acceptableAnswer = true;
     
    							// This assigns boolean true to the variable done, which will make the outer while loop will stop executing
    							done = true;
    						}
     
    						else {
     
    							// This prints out a message, and asks the user to input a response.
    							System.out.print("\n" + "Invalid input." + "\n" + "Would you like to enter another password" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    						}
    					}
    				}
    		}
     
    		else {
     
    			// This block will only execute if the file used to create fileCheck does not exist.  This method will create an empty file with a 
    			// name that is equal to the String that was used to create the File object fileCheck
    			fileCheck.createNewFile();
     
    			// This prints out a message
    			System.out.println("\n" + "This program will require you to enter a password that meets the following" + "\n" + "criteria:" + "\n");
     
    			// This prints out a message
    			System.out.println("The password must have at least 8 characters, but no more than 10 characters.");
     
    			// This prints out a message
    			System.out.println("The password must have at least one capital letter.");
     
    			// This prints out a message
    			System.out.println("The password must have at least one special character (ex. !, @, #, etc.)");
     
    			// This prints out a message
    			System.out.println("The password cannot be one that is already stored in the password file." + "\n");
     
    			// This prints out a message, and asks the user to input a response.
    			System.out.print("Please enter your password: ");
     
    			// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    			boolean done = false;
     
    			// This while loop will repeat until the user is done with this program
    			while (!done) {
     
    				// This reads in the user input and stores it in the variable userPassword
    				String userPassword = userInput.readLine();
     
    				// This creates a PasswordChecker object using the String contained in the variable userPassword.  The object is stored in
    				// the variable checker
    				PasswordChecker checker = new PasswordChecker(userPassword);
     
    				// This checks to see if the checkLength() method of the PasswordChecker class will return true
    				if (checker.checkLength()) {
     
    					// This checks to see if the checkCapital() method of the PasswordChecker class will return true
    					if (checker.checkCapital()) {
     
    						// This checks to see if the checkSpecial() method of the PasswordChecker class will return true
    						if (checker.checkSpecial()) {
     
    							// This checks to see if the checkNoDuplicate() method of the PasswordChecker class will return true
    							if (checker.checkNoDuplicate(fileName)) {
     
    								// This prints out a message
    								System.out.println("Valid password.");
     
    								// It is possible that an error will occur when the password file is opend for output, hence why a try/catch block
    								// is used
    								try{
     
    									// This opens the file fileName for output
    									FileWriter fstream = new FileWriter(fileName, true);
     
    									// This object is what is used to output data tot he file fileName
    									BufferedWriter out = new BufferedWriter(fstream);
     
    									// This writes whatever is in the first set of parentheses (in this case, it is checker.getPassword()) to
    									// the file that was opend for output (in this case, fileName)
    									out.write(checker.getPassword());
     
    									// This writes whatever is in the first set of parentheses (in this case, a newline character) to
    									// the file that was opend for output (in this case, fileName)
    									out.write("\n");
     
    									// This closes the file
    									out.close();
     
    									// This prints out a message, and asks the user to input a response.
    									System.out.print("\n" + "Would you like to view the password file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    									// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    									acceptableAnswer = false;
     
    									// This while loop will repeat until the user enters a valid response to the previous request
    									while(!acceptableAnswer) {
     
    										// This reads in the user input and stores it in the variable answer
    										String answer = userInput.readLine();
     
    										// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    										if (answer.equalsIgnoreCase("Y")) {
     
    											// This opens the file fileName so that it can be read
    											FileInputStream fstream2 = new FileInputStream(fileName);
     
    											// These next two declarations make it possible to actually read the given file and get its contents.
    											DataInputStream in2 = new DataInputStream(fstream2);
     
    											BufferedReader bufferRead2 = new BufferedReader(new InputStreamReader(in2));
     
    											// This creates the variable stringLine to be used in the upcoming while loop
    											String stringLine2;
     
    											// This while loop reads the contents of the file fileName until it reaches the end.  Whenever it reads a line, it stores
    											// the line in the variable stringLine (overwritting what was previously stored)
    											while ((stringLine2 = bufferRead2.readLine()) != null) {
     
    												// This prints out what is stored in variable stringLine2
    												System.out.println(stringLine2);
    											}	
     
    											// This closes the file fileName
    											in2.close();
     
    											// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    											acceptableAnswer = true;
    										}
     
    										// This if statement checks to see if the user's input was equal to "N", ignoring the case of the input
    										else if (answer.equalsIgnoreCase("N")) {
     
    											// This assigns boolean true to the variable acceptableAnswer, which will make the outer while loop will stop executing
    											acceptableAnswer = true;
    										}
     
    										else {
     
    										// This prints out a message, and asks the user to input a response.
    										System.out.print("Invalid input." + "\n" + "Would you like to view the password file's contents" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    										}
    									}
     
    								}
     
    								// If an exception does occur when opening fileName for output, this catch block will execute, print out a 
    								// message, and the program will terminate								
    								catch (Exception error){
     
    									System.err.println("Error: " + error.getMessage());
    								}
    							}
     
    							else {
     
    								// This prints out a message
    								System.out.println("This password is already in the password file.");
    							}
    						}
     
    						else {
     
    							// This prints out a message
    							System.out.println("Password does not contain a special character.");
    						}
    					}
     
    					else {
     
    						// This prints out a message
    						System.out.println("Password does not contain a capital letter.");
    					}
    				}
     
    				else {
     
    					// This prints out a message
    					System.out.println("Invalid password length.");
    				}
     
    				// This prints out a message, and asks the user to input a response.
    				System.out.print("\n" + "Do you want to enter another password" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
     
    				// This is used as a condition to keep the upcoming while loop executing for as long as necessary
    				acceptableAnswer = false;
     
    				// This while loop will repeat until the user enters a valid response to the previous request
    				while(!acceptableAnswer) {
     
    					// This reads in the user input and stores it in the variable answer
    					String answer = userInput.readLine();
     
    					// This if statement checks to see if the user's input was equal to "Y", ignoring the case of the input
    					if (answer.equalsIgnoreCase("Y")) {
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the inner while loop will stop executing
    						acceptableAnswer = true;
     
    						// This prints out a message
    						System.out.println("\n" + "The password must have at least 8 characters, but no more than 10 characters.");
     
    						// This prints out a message
    						System.out.println("The password must have at least one capital letter.");
     
    						// This prints out a message
    						System.out.println("The password must have at least one special character (ex. !, @, #, etc.)");
     
    						// This prints out a message
    						System.out.println("The password cannot be one that is already stored in the password file." + "\n");
     
    						// This prints out a message, and asks the user to input a response.
    						System.out.print("Please enter your password: ");
    					}	
     
    					else if (answer.equalsIgnoreCase("N")) {
     
    						// This assigns boolean true to the variable acceptableAnswer, which will make the inner while loop will stop executing
    						acceptableAnswer = true;
     
    						// This assigns boolean true to the variable done, which will make the outer while loop will stop executing
    						done = true;
    					}
     
    					else {
     
    						// This prints out a message, and asks the user to input a response.
    						System.out.print("\n" + "Invalid input." + "\n" + "Would you like to enter another password" + "\n" + "(type Y for yes or N for no, and then press Enter/Return)? ");
    					}
    				}
    			}
    		}
     
    		// This will close the userInput channel
    		userInput.close();
    	}
    }


    Here is the code for the java class that does have a UML diagram:
    /**
    * This class is used to generate PasswordChecker objects, which have a String called password as a parameter for its construction.  There is also
    * a char array that is used for checking the String password, but it cannot be accessed otherwise.  The methods for this class include
    * getPassword(), checkLength(), checkCapital(), checkSpecial(), and checkDuplicate
    * @author	*****
    * @since	2012-08-25
    */
     
    // This specifies that this class is part of the package called tools.  If a program wishes to use this class, then it just needs to have the 
    // statement "include tools.* at the top of the program
    package tools;
     
    // This imports all java Input/Output methods so that they can be used by these class methods
    import java.io.*;
     
    public class PasswordChecker {
     
    	// The password that will be checked by the members of the PasswordChecker class
    	private String password;
     
    	// This array has all special characters in it.  It is used to check to see that password has at least one of these characters in it.
    	private char[] specialChar = {'!','@','#','$','%','^','&','*','(',')','-','_','=','+','[','{',']','}','|',';',':',',','<','.','>','/','?'};
     
    	/**
    	* The constructor for PasswordChecker
    	* @param userPassword A String that is used to represent the password
    	*/
    	public PasswordChecker(String userPassword) {
     
    			password = userPassword;
    	}
     
    	/**
    	* The constructor for PasswordChecker that is used if there is not a password passed to PasswordChecker.  The password variable is assigned
    	* a blank String
    	*/
    	public PasswordChecker() {
     
    			password = "";
    	}
     
    	/**
    	* Returns the password used to construct the PasswordChecker object
    	* @return the password used to construct the PasswordChecker object
    	*/
    	public String getPassword() {
     
    		return password;
    	}
     
    	/**
    	* Checks to see if the password String is greater than or equal to 8 characters in length and less than or equal to 10 characters in length.
    	* @return boolean true if the password String is greater than or equal to 8 characters in length and less than or equal to 10 characters in 
    	* length, boolean false otherwise
    	*/
    	public boolean checkLength() {
     
    		// the length of the password String.  It is used in the upcoming if statement
    		int length = password.length();
     
    		// Checks to see if the length of the password is greater than or equal to 8 and less than or equal to 10
    		if (length >= 8 && length <= 10) {
     
    			return true;
    		}
     
    		else {
     
    			return false;
    		}
    	}
     
    	/**
    	* Checks to see if the password String has at least 1 capital letter in it.  
    	* @return boolean true if the password String has at least 1 capital letter in it, boolean false otherwise
    	*/
    	public boolean checkCapital() {
     
    		// This for loop iterates for a duration equal to the length of the password String, or until the nested if statement is true
    		for (int i = 0; i <= password.length() - 1; i++) {
     
    			// This variable is assigned the character that is equal to the character in the password String whose placement is 'i'.  For example,
    			// if i = 0 and password = "cat", then character = 'c' (because 'c' is the 0th character in the String "cat").  When i = 1, 
    			// character = 'a'
    			char character = password.charAt(i);
     
    			// This if statement checks to see if the char in the variable character is a capital letter.  If it is, then the function returns
    			// boolean true and stops.
    			if (Character.isUpperCase(character)) {
     
    				return true;
    			}
    		}
     
    		// This happens if the for loop iterates for its entire duration and the nested if statement is never true (which means the password
    		// String did not have a capital letter).
    		return false;
    	}
     
    	/**
    	* Checks to see if the password String has at least 1 special character in it.
    	* @return boolean true if the password String has at least 1 special character in it, boolean false otherwise
    	*/
    	public boolean checkSpecial() {
     
    		// This for loop iterates for a duration equal to the length of the password String, or until the nested if statement is true
    		for (int i = 0; i <= password.length() - 1; i++) {
     
    			// This variable is assigned the character that is equal to the character in the password String whose placement is 'i'.  For example,
    			// if i = 0 and password = "cat", then character = 'c' (because 'c' is the 0th character in the String "cat").  When i = 1, 
    			// character = 'a'
    			char character = password.charAt(i);
     
    			// This for loop iterates for a duration equal to the size of the specialChar array, or until the nested if statemet is true
    			for (int j = 0; j <= specialChar.length - 1; j++) {
     
    				// This if statement checks to see if the char in the variable character is a special character.  If it is, then the function
    				// boolean true and stops.
    				if (character == specialChar[j]) {
     
    					return true;
    				}
    			}
    		}
     
    		// This happens if the outer for loop iterates for its entire duration and the nested if statement, in the nested for loop, is never true 
    		// (which means the password String did not have a capital letter).
    		return false;
    	}
     
    	/**
    	* Checks the given file to see if there is a String that is exactly the same as the password String.  If the file cannot be found, or there
    	* is some other problem with opening the given file, then an exception will be caught and the method will end.
    	* @param fileName a String that is the filename of a file that should contain String passwords.  The contained String passwords will be 
    	* compared with the String password stored in the PasswordChecker object.
    	* @return boolean true if there is not a String in fileName that is exactly the same as the password String, boolean false otherwise
    	*/
    	public boolean checkNoDuplicate(String fileName) {
     
    		// There is a chance an error will occur, such as the file with name fileName not existing or the file not opening correctly.  Hence why
    		// a Try/Catch block is used.
    		try {
     
    			// This opens the file whose name is provided as the argument for this method
    			FileInputStream fstream = new FileInputStream(fileName);
     
    			// These next two declarations make it possible to actually read the given file and get its contents.
    			DataInputStream in = new DataInputStream(fstream);
     
    			BufferedReader bufferRead = new BufferedReader(new InputStreamReader(in));
     
    			// This creates a String variable called stringLine, which is to be used in the upcoming while loop
    			String stringLine;
     
    			// This while loop will read every line in the file until it reaches the end of the file (in which case the the variable
    			// stringLine will be NULL) or until a password is found in the file that is the same as the password contained in the 
    			// PasswordChecker object
    			while ((stringLine = bufferRead.readLine()) != null) {
     
    				// This is where the loop checks to see if the file contains the same password contained in the PasswordChecker object.
    				// If this happens, then the file is closed, and the method returns FALSE
    				if (password.equals(stringLine)) {
     
    					// This closes the file that was opened for input
    					in.close();
     
    					return false;
    				}
    			}
     
    			// If no match is found, the file is closed, and the method returns TRUE
    			in.close();
     
    			return true;
    		}
     
    		// If an exception does occur, this catch block will execute, a message will be printed, and the method will stop executing
    		catch (Exception error){
     
    			System.err.println("Error: " + error.getMessage());
    		}
     
    		// If an error occurs, then the method returns FALSE
    		return false;
    	}
    }


    Both work BTW, I just need the UML diagram for the first one


  2. #2
    Junior Member psabbate's Avatar
    Join Date
    Aug 2012
    Posts
    20
    My Mood
    Amused
    Thanks
    0
    Thanked 5 Times in 4 Posts

    Default Re: UML diagram

    I'm sorry. I don't understand your problem. You need an UML diagram right? Are you using any tool? Can you give us more information?
    Everyone wants to go to heaven ... but nobody wants to die

    Nissi Group, Servicios IT,
    Diseņo Web, Desarrollo de Software, SEO,
    LinkedIn

Similar Threads

  1. Java UML diagram question
    By colerelm in forum Java Theory & Questions
    Replies: 1
    Last Post: November 29th, 2011, 08:50 PM
  2. UML Class Diagram
    By LDM91 in forum Java Theory & Questions
    Replies: 4
    Last Post: December 27th, 2010, 12:04 PM
  3. Replies: 2
    Last Post: April 21st, 2010, 10:25 AM
  4. need API for Connection Routing in Interactive Diagram Editor
    By pavan arepu in forum AWT / Java Swing
    Replies: 2
    Last Post: April 21st, 2010, 10:19 AM
  5. UML Diagram Help
    By chizzle in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2010, 04:12 AM