Customer - } public boolean equals( Object o) { if (o...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.lang.*; i public class Customer implements Comparable { private String name; private int age; private Date enrollDate; public Customer() { this(new String(), 0, new Date()); } public Customer(String name) { this(name, 0, new Date()); } public Customer(String name, int age, Date enrollDate) { setName(name); setAge(age); setEnrollDate(enrollDate); } public void setName(String name) { this.name = name; } public String getName() { return name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Date getEnrollDate() { return enrollDate; } public void setEnrollDate(Date enrollDate) { this.enrollDate = enrollDate; } public void printCustInfo() { System.out.println(name+","+age+","+enrollDate);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public boolean equals( Object o) { if (o instanceof Customer) { return (compareTo(o) == 0); } return false; } public int compareTo( Object object) { /*if (object instanceof Customer) { Customer customer = (Customer) object; if (getName().equals(customer.getName())) { if(getAge()==customer.getAge()) { if (getEnrollDate().equals(customer.getEnrollDate())) { return 0; } else { return getEnrollDate().compareTo(customer.getEnrollDate()); } } else if (getAge() > customer.getAge()) { return -1; } else if (getAge() < customer.getAge()) { return 1; } } else { return getName().compareTo(customer.getName()); } } else return -1; */ }return true; }...
View Full Document

Page1 / 2

Customer - } public boolean equals( Object o) { if (o...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online