⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 account.java

📁 文件说明java模式
💻 JAVA
字号:




public class Account {

  String firstName;
  String lastName;
  final String ACCOUNT_DATA_FILE = "AccountData.txt";

 //constructor
  public Account(String fname, String lname) {
    firstName = fname;
    lastName = lname;
  }

  //check if the last name is correct or not
  // the length of last name should equal to
  // or greater than 6
  public boolean isValid() {
    /*
     	Let's go with simpler validation
     	here to keep the example simpler.
     */

    if (getLastName().trim().length() < 6)
      return false;

    return true;
  }

  // save last name and first name
  public boolean save() {
    FileUtil futil = new FileUtil();
    String dataLine = getLastName() + "," + getFirstName();
    return futil.writeToFile(ACCOUNT_DATA_FILE, dataLine,
           true, true);

  }

  // get first name and last name
  public String getFirstName() {
    return firstName;
  }
  public String getLastName() {
    return lastName;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -