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

📄 address.java

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



public class Address {

  String address;
  String city;
  String state;

 // final String ADDRESS_DATA_FILE = "Address.txt";

 final String ADDRESS_DATA_FILE = "AddressInfo.txt";

 //constructor of address
  public Address(String add, String cty, String st) {
    address = add;
    city = cty;
    state = st;
  }

  //check if the address is correct or not, if
  // the length of state is greater than or equal to 2,
  // then the address is valid
  public boolean isValid() {
    /*
     	The address validation algorithm
     	could be complex in real-world
     	applications.
     	Let's go with simpler validation
     	here to keep the example simpler.
     */
    if (getState().trim().length() < 2)
      return false;

    return true;
  }

  //save the user input to adress file
  public boolean save() {
    FileUtil futil = new FileUtil();
    String dataLine = getAddress() + "," + getCity() + "," +
                      getState();
    return futil.writeToFile(ADDRESS_DATA_FILE, dataLine,
           true, true);
  }

  public String getAddress() {
    return address;
  }
  public String getCity() {
    return city;
  }
  public String getState() {
    return state;
  }

}

⌨️ 快捷键说明

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