Homework 10 - Homework
輸入說明
- 在程式一開始會先輸入
功課總截止時間
new
為新增作業,後面接續兩個String
,分別為作業名稱
及作業繳交時間
,作業繳交時間
格式為YY-MM-DD
submit
為繳交作業end
為輸入結束程式,最後印出結果。
輸出說明
- 需要檢查是否有繳交作業狀態,及是否逾期
- 尚未繳交且逾期,則會顯示該功課
遲交
- 尚未繳交則還未逾期,則會顯示
記得要作業
- 已經繳交,則會顯示
已經繳交
- 尚未繳交且逾期,則會顯示該功課
額外說明
- 需以物件導向方式設計,請依此為基礎撰寫:
public class Homework {
private String name, time;
private boolean state;
public void submit() {
}
public boolean compareDate(String deadline) {
// 這邊使用 String.split 去將該 String 分割成一個陣列,並用 Integer.parseInt 將字串轉型態為整數去做大小比較
}
}
輸入範例
2016-06-01
new 作業一 2016-03-23
new shape2D 2016-05-22
new 果汁機 2016-06-24
submit 作業一
new 期末Project 2016-06-30
end
輸出範例
Hint
class String
public String[] split(String regex)
Splits this string around matches of the given regular expression.
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
The string "boo:and:foo", for example, yields the following results with these expressions:
Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }
Parameters: regex - the delimiting regular expression
Returns: the array of strings computed by splitting this string around matches of the given regular expression
class Integer
public static int parseInt(String s) throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value or an ASCII plus sign '+' ('\u002B') to indicate a positive value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.
Parameters: s - a String containing the int representation to be parsed
Returns: the integer value represented by the argument in decimal.