/**
* roonten
*
* Copyright (c)
* All rights reserved
*
* This toolkit all my items one is the last edition
* some handy discreteness for me
* for use it
*/
package roonten
import java
/**
* <div>
* The <code>IdentityCard</code> class is implements IIdentityCard
* interface
* card need to using methods
* part this identity card must be right
* </div>
*
* @author Roon Ten
* @version
*/
public class IdentityCard {
private char[] chrs;
private final String CHECK_STRING
/**
* Create an object of this class by an scheduled identity card
* @param obj
*/
public IdentityCard(Object obj) {
chrs = getChrs(obj);
}
/**
* Get a team for character by this identity card
* @param obj
* @return
*/
private char[] getChrs(Object obj) {
return String
}
/**
* If this identity card is legal one
*/
public boolean isLegalityFormat() {
return String
}
/**
* If the year this identity card is legal one
*/
public boolean isLegalityYear() {
boolean isPass = false;
if (chrs != null && chrs
int year = Integer
+
int current = Calendar
isPass = year >= current
}
return isPass;
}
/**
* If the month this identity card is legal one
*/
public boolean isLegalityMonth() {
boolean isPass = false;
if (chrs != null && chrs
int month = Integer
isPass = month >
}
return isPass;
}
/**
* If the day this identity card is legal one
*/
public boolean isLegalityDay() {
boolean isPass = false;
if (chrs != null && chrs
int yy = Integer
+
int month = Integer
int day = Integer
Year year = new Year(yy);
isPass = year
}
return isPass;
}
/**
* If the last character this identity card is legal one
*/
public boolean isLegalityEnd() {
boolean isPass = false;
if (chrs != null && chrs
int num = (Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
+ Integer
switch (num) {
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
case
isPass =
break;
}
}
return isPass;
}
/**
* Get the length this identity card
*/
public int getLength() {
return this
}
/**
* If it is a legal one
*/
public boolean isEffective() {
boolean isValid = false;
isValid = isLegalityFormat();
if (isValid) {
isValid = isLegalityYear();
if (isValid) {
isValid = isLegalityMonth();
if (isValid) {
isValid = isLegalityDay();
if (isValid) {
isValid = isLegalityEnd();
}
}
}
}
return isValid;
}
}
/**
* The <code>Year</code> class use to get a month day of a year
* @author TenRoon
* @version
*/
class Year {
/**
* Current year
*/
private int Year;
/**
* January days
*/
public static final int JAN_DAY =
/**
* February days of a year
* @param year
* @return
*/
public static final int FEB_DAY(int year) {
int feb_Day =
if ((year %
feb_Day =
}
return feb_Day;
}
/**
* March days
*/
public static final int MAR_DAY =
/**
* April days
*/
public static final int APR_DAY =
/**
* May days
*/
public static final int MAY_DAY =
/**
* June days
*/
public static final int JUN_DAY =
/**
* July days
*/
public static final int JUL_DAY =
/**
* August days
*/
public static final int AUG_DAY =
/**
* September days
*/
public static final int SEP_DAY =
/**
* Octomber days
*/
public static final int OCT_DAY =
/**
* November days
*/
public static final int NOV_DAY =
/**
* December days
*/
public static final int DEC_DAY =
/**
* Create a object of a current year
* @param Year
*/
public Year(int Year) {
this
}
/**
* Get the max day a month
* @param month
* @return
*/
public int getMaxDay(int month) {
int maxDay =
switch (month) {
case
maxDay = JAN_DAY;
break;
case
maxDay = FEB_DAY(this
break;
case
maxDay = MAR_DAY;
break;
case
maxDay = APR_DAY;
break;
case
maxDay = MAY_DAY;
break;
case
maxDay = JUN_DAY;
break;
case
maxDay = JUL_DAY;
break;
case
maxDay = AUG_DAY;
break;
case
maxDay = SEP_DAY;
break;
case
maxDay = OCT_DAY;
break;
case
maxDay = NOV_DAY;
break;
case
maxDay = DEC_DAY;
break;
}
return maxDay;
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25785.html