forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDate.java
More file actions
33 lines (29 loc) · 741 Bytes
/
Copy pathDate.java
File metadata and controls
33 lines (29 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* class for date
*/
public class Date {
private int year;
private int month;
private int day;
//constructor
public Date() {
this.year = 2019;
this.month = 11;
this.day = 4;
}
//value constructor
public Date(int year, int month, int day) {
this.year = year;
this.month = month;
this.day = day;
}
//print
public static void printDate(Date date) {
System.out.printf("%d/%d/%d\n", date.month, date.day, date.year);
}
public static void main(String[] args) {
Date birthday = new Date(1998, 4, 27);
System.out.println(birthday);
printDate(birthday);
}
}