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

📄 creditcard.java

📁 USB设计的一些源码!适合与USB开发的同学!还是蛮不错的!我用过一些!
💻 JAVA
字号:
public class CreditCard {

  String cardType;
  String cardNumber;
  String cardExpDate;

  public static final String CC_DATA_FILE = "CC.txt";

  public static final String DISCOVER = "Discover";
  public static final String MASTER = "Master";
  public static final String VISA = "Visa";
  public static final String VALIDCARD = "Valid Card";

  public CreditCard(String ccType, String ccNumber,
                    String ccExpDate) {
    cardType = ccType;
    cardNumber = ccNumber;
    cardExpDate = ccExpDate;
  }

  public boolean isValid() {
    /*
     	Let's go with simpler validation
     	here to keep the example simpler.
     */
    if (getCardType().equals(CreditCard.VISA)) {
      return (getCardNumber().trim().length() == 16);
    }
    if (getCardType().equals(CreditCard.DISCOVER)) {
      return (getCardNumber().trim().length() == 15);
    }
    if (getCardType().equals(CreditCard.MASTER)) {
      return (getCardNumber().trim().length() == 16);
    }

    return false;
  }
  public boolean save() {
    FileUtil futil = new FileUtil();
    String dataLine =
      getCardType() + "," + getCardNumber() + "," +
      getCardExpDate();
    return futil.writeToFile(CC_DATA_FILE, dataLine, true,
           true);
  }
  public String getCardType() {
    return cardType;
  }
  public String getCardNumber() {
    return cardNumber;
  }
  public String getCardExpDate() {
    return cardExpDate;
  }

}

⌨️ 快捷键说明

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