title: PAT for School - Bank App (Methods and Reading Text Files with Delimitation)
body: <p>Here are my program's methods:</p>
  
  <pre><code>package ItPatPackage;
  
  //Defines a banking Client
  
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import javax.swing.JOptionPane;
  
  public class Client
  {
  
  //attributes
  private String clientName;
      private String clientPass;
  private int accountNum;
  private double currentBal;
  private double savingsBal;
      private boolean verify;
  
  //default constructor
  
  public Client()
  {
      clientName = "";
              clientPass = "";
      accountNum = 0;
      currentBal = 0.0;
      savingsBal = 0.0;
              verify = false;
  
  }
  //parameterised constructor
  private Client(String username,String password,int accNum, double
  curBal,double savBal, boolean ver)
  {
      clientName = username;
              clientPass = password;
      accountNum = accNum;
      currentBal = curBal;
      savingsBal = savBal;
              verify = ver;
  }
  
  //get methods
  public String getClientName()
  {
      return clientName;
  }
      public String getClientPass()
      {
              return clientPass;
      }
  public int getAccNum()
  {
      return accountNum;
  }   
   public double getCurrentBal()
  {
      return currentBal;
  }
  public double getSavingsBal()
  {
      return savingsBal;
  }   
      public boolean getClientVerify()
  {
      return verify;
  }
  
  //mutator methods
  public void setClientName(String username)
  {
      clientName= username;
  }
  public void setClientPass(String password)
  {
      clientPass = password;
  }   
  
  //deposit
  public void depositSavings(double ds)
  {
      savingsBal = savingsBal + ds;
  }
  public void depositCurrent(double dc)
  {
      currentBal = currentBal + dc;
  }
  //withdraw
  public void withdrawSavings(double ws)
      {
              if (ws&lt;savingsBal){
              savingsBal = savingsBal - ws;
              }
              else{
                  JOptionPane.showMessageDialog(null, "Insufficient Funds. 
  \nYour Savings Balance is: R" + savingsBal);
              }
      }
      public void withdrawCurrent(double wc)
      {
              if (wc&lt;currentBal){
              currentBal = currentBal - wc;
              }
              else{
                  JOptionPane.showMessageDialog(null, "Insufficient Funds.
  \nYour Current Balance is: R" + currentBal);
              }
      }
  //transfer  
      public void transferStoC(double sc)
      {
              if (sc&lt;savingsBal){
              savingsBal = savingsBal - sc;
              currentBal = savingsBal + sc;
              }
              else{
                  JOptionPane.showMessageDialog(null, "Insufficient Funds.
   \nYour Savings Balance is: R" + savingsBal);
              }
      }
      public void transferCtoS(double cs)
      {
              if (cs&lt;savingsBal){
              savingsBal = savingsBal + cs;
              currentBal = savingsBal - cs;
              }
              else{
                  JOptionPane.showMessageDialog(null, "Insufficient Funds. 
  \nYour Current Balance is: R" + currentBal);
              }
      }
      //: Creates New Client
      public void newClient(String username,String password) throws 
  IOException
      {
          clientName = username;
          clientPass = password;
          accountNum = (int)(Math.random()*100000);
          savingsBal = (int)((Math.random()*100000000)) / 100.0;
          currentBal = (int)((Math.random()*100000000)) / 100.0;
          BufferedWriter bw = new BufferedWriter (new     
  FileWriter("ClientDatabase.txt",true));
  
   bw.write(clientName+"_"+clientPass+"_"+accountNum+"_"+currentBal+"_"+savingsBal+"_");
              bw.newLine();
              bw.close();
                  }
      //: Verifies new Client (THIS IS WHAT DOESN'T WORK, ALONG WITH THE CODE I WILL POST AFTER THIS
      public boolean clientVerify(String checkUsername, String checkPassword)
      {
          try 
          {
              BufferedReader br = new BufferedReader(new FileReader("ClientDatabase.txt"));
              String s;
              while ((s = br.readLine()) != null){
                  String line = br.readLine();
                  String part[] = line.split("_");
                  if ((part[0].equals(checkUsername))|(part[1].equals(checkPassword))){
                      accountNum = Integer.parseInt(part[3]);
                      currentBal = Double.parseDouble(part[4]);
                      savingsBal = Double.parseDouble(part[5]);
                      verify = true;
                  }
              }
          }
          catch(IOException | NumberFormatException e)
          {
              JOptionPane.showMessageDialog(null, "Error");
          }
          return verify;
      }
  }
  </code></pre>
  
  <p>My Log In Button's code is as follows:</p>
  
  <pre><code>private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                         
  String checkUsername = txfUsername.getText();
  String checkPassword = txfPassword.getText();
  Client cl1 = new Client();
  boolean verify = cl1.clientVerify(checkUsername, checkPassword);
  if (verify==true){
      OptionsPage options = new OptionsPage();
      options.setVisible(true);
      this.setVisible(false);
  }
  else{
      JOptionPane.showMessageDialog(null, "Username/Password do not match or     do not exist.");
  }    
  }
  </code></pre>
  
  <p>I have been having trouble with my "clientVerify" method, which works for my "Log In Button", as seen above, and I'm not sure which part is wrong.. It doesn't seem to work, and I don't think that my BufferedReader is reading from the text file properly. (That's the only thing I could think of that may be wrong, correct me if it's something else.)
  All that comes up no matter the user input is a JOptionPane Message Dialog saying "Error", and then "Username/Password do not match or do not exist". I have checked the text file and the information is all there perfectly seperated by "_".
  Another possibility is that my methods aren't changing from what I have entered them as in the default constructor. I'll admit I'm new to methods so that could be a possibility.</p>
  
  <p>Any help will be greatly appreciated.</p>