求这到swift的做法 球补全

[复制链接]
56 1
public class Date implements Comparable {
private static final int[] DAYS = { 0, 31, 29, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31 };
private final int month;
private final int day;
private final int year;
// month (between 1 and 12)
// day (between 1 and DAYS[month]
// year
/**
* Initializes a new date from the month, day, and year.
* @param month the month (between 1 and 12)
* @param day the day (between 1 and 28-31, depending on the month) * @param year the year
* @throws IllegalArgumentException if this date is invalid
*/
public Date(int month, int day, int year) {
}
/**
* Initializes new date specified as a string in form MM/DD/YYYY. * @param date the string representation of this date
* @throws IllegalArgumentException if this date is invalid
*/
public Date(String date) {
}
/**
* Return the month.
* @return the month (an integer between 1 and 12) */
public int month() {
}
/**
* Returns the day.
* @return the day (an integer between 1 and 31) */
public int day() {
}
/**
* Returns the year. * @return the year */
public int year() {
}
// is the given date valid?
private static boolean isValid(int m, int d, int y) {
}
// is y a leap year?
private static boolean isLeapYear(int y) {
}
/**
* Returns the next date in the calendar.
*
* @return a date that represents the next day after this day */
public Date next() {
}
/**
* Compares two dates chronologically.
*
* @param that the other date
* @return {@code true} if this date is after that date; {@code false}
otherwise */
public boolean isAfter(Date that) {
}
/**
* Compares two dates chronologically.
*
* @param that the other date
* @return {@code true} if this date is before that date; {@code false}
otherwise */
public boolean isBefore(Date that) {
}
/**
* Compares two dates chronologically.
*
* @return the value {@code 0} if the argument date is equal to this
date;
* a negative integer if this date is chronologically less than
* the argument date; and a positive ineger if this date is
chronologically
* after the argument date
*/
@Override
public int compareTo(Date that) {
}

/**
* Returns a string representation of this date.
*
* @return the string representation in the format MM/DD/YYYY */
@Override
public String toString() {
return month + "/" + day + "/" + year;
}
/**
* Compares this date to the specified date.
*
* @param other the other date
* @return {@code true} if this date equals {@code other}; {@code false}
otherwise */
@Override
public boolean equals(Object other) {
}
/**
* Returns an integer hash code for this date. *
* @return an integer hash code for this date */
@Override
public int hashCode() {
}
/**
* Unit tests the {@code Date} data type. *
* @param args the command-line arguments */
public static void main(String[] args) {
Date today = new Date(2, 25, 2004);
StdOut.println(today);
for (int i = 0; i < 10; i++) {
today = today.next();
StdOut.println(today);
}
StdOut.println(today.isAfter(today.next()));
StdOut.println(today.isAfter(today));
StdOut.println(today.next().isAfter(today));
Date birthday = new Date(10, 16, 1971);
StdOut.println(birthday);
for (int i = 0; i < 10; i++) {
birthday = birthday.next();
StdOut.println(birthday);

} }
}

举报 使用道具

回复

1 个评论

banyao  注册会员  发表于 2019-2-22 00:39:34  | 显示全部楼层
public class Date implements Comparable<Date> {
    private static final int[] DAYS = { 0, 31, 29, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31 };
private final int month;
private final int day;
private final int year;
// month (between 1 and 12)
// day   (between 1 and DAYS[month]
// year
/**
* Initializes a new date from the month, day, and year.
* @param month the month (between 1 and 12)
* @param day the day (between 1 and 28-31, depending on the month) * @param year the year
* @throws IllegalArgumentException if this date is invalid
*/
public Date(int month, int day, int year) {
}
/**
* Initializes new date specified as a string in form MM/DD/YYYY. * @param date the string representation of this date
* @throws IllegalArgumentException if this date is invalid
*/
public Date(String date) {
}
/**
* Return the month.
* @return the month (an integer between 1 and 12) */
public int month() {
}
/**
* Returns the day.
* @return the day (an integer between 1 and 31) */
public int day() {
}
/**
* Returns the year. * @return the year */
public int year() {
}
// is the given date valid?
private static boolean isValid(int m, int d, int y) {
}
// is y a leap year?
private static boolean isLeapYear(int y) {
}
/**
* Returns the next date in the calendar.
*
* @return a date that represents the next day after this day */
public Date next() {
}
/**
* Compares two dates chronologically.
*
* @param that the other date
* @return {@code true} if this date is after that date; {@code false}
otherwise */
public boolean isAfter(Date that) {
}
/**
* Compares two dates chronologically.
*
* @param that the other date
* @return {@code true} if this date is before that date; {@code false}
otherwise */
public boolean isBefore(Date that) {
}
/**
* Compares two dates chronologically.
*
* @return the value {@code 0} if the argument date is equal to this
date;
*         a negative integer if this date is chronologically less than
*         the argument date; and a positive ineger if this date is
  chronologically
*         after the argument date
*/
@Override
public int compareTo(Date that) {
}

/**
* Returns a string representation of this date.
*
* @return the string representation in the format MM/DD/YYYY */
@Override
public String toString() {
    return month + "/" + day + "/" + year;
}
/**
* Compares this date to the specified date.
*
* @param other the other date
* @return {@code true} if this date equals {@code other}; {@code false}
otherwise */
@Override
public boolean equals(Object other) {
}
/**
* Returns an integer hash code for this date. *
* @return an integer hash code for this date */
@Override
public int hashCode() {
}
/**
* Unit tests the {@code Date} data type. *
* @param args the command-line arguments */
public static void main(String[] args) {
    Date today = new Date(2, 25, 2004);
    StdOut.println(today);
    for (int i = 0; i < 10; i++) {
        today = today.next();
        StdOut.println(today);
    }
    StdOut.println(today.isAfter(today.next()));
    StdOut.println(today.isAfter(today));
    StdOut.println(today.next().isAfter(today));
    Date birthday = new Date(10, 16, 1971);
    StdOut.println(birthday);
    for (int i = 0; i < 10; i++) {
        birthday = birthday.next();
        StdOut.println(birthday);

} }
}

举报 使用道具

回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

ios.irunthink.com
搜索
热搜: iOS swift 下拉刷新

图文热点

更多

开发教程

更多

客服中心

400-800 周一至周日 9:30-17:30 仅收市话费

关注我们

  • 微信扫描
  • 关注微信
关于我们
关于我们
友情链接
联系我们
帮助中心
精贴推荐
源码上传
注册登录
服务支持
资源下载
关注我们
官方微博
官方空间
快速回复 返回顶部 返回列表