import java.util.Calendar; import java.util.Date; public class Transfer { private Date issueDate; private String issueStation; public Transfer(String station) { this.issueDate = new Date(); this.issueStation = station; } public Date getIssueDate() { return new Date(this.issueDate.getTime()); } public String getStation() { return this.issueStation; } public int getDay() { Calendar cal = Calendar.getInstance(); cal.setTime(this.issueDate); return cal.get(Calendar.DAY_OF_YEAR); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Transfer other = (Transfer) obj; if (issueDate == null) { if (other.issueDate != null) { return false; } } else if (!issueDate.equals(other.issueDate)) { return false; } if (issueStation == null) { if (other.issueStation != null) { return false; } } else if (!issueStation.equals(other.issueStation)) { return false; } return true; } @Override public String toString() { return "Time issued: " + this.issueDate + ", Day: " + this.getDay() + ", Not valid at: " + this.getStation(); } public static void main(String[] args) { Transfer t = new Transfer("DOWNSVIEW"); System.out.println(t); } }