/** * Write a description of class Pothole here. * * @author Dale Reed * @version 3/17/2009 */ public class Pothole { // instance variables int number; Date5 date; int address; String street; int severity; // Constructors // fully qualified constructor public Pothole( int theNumber, Date5 theDate, int theAddress, String theStreet, int theSeverity) { number = theNumber; date = theDate; address = theAddress; street = theStreet; severity = theSeverity; } // copy constructor public Pothole( Pothole otherPotHole) { number = otherPotHole.number + 1; date = new Date5( otherPotHole.date); address = otherPotHole.address; street = otherPotHole.street; severity = otherPotHole.severity; } public Pothole( int theNumber) { // chain to fully qualified constructor this( theNumber, new Date5(), 1000, "State St.", 1); } // like fully qualified constructor, except no Date supplied as parameter public Pothole( int theNumber, int theAddress, String theStreet, int theSeverity) { // chain to fully qualified constructor this( theNumber, new Date5(), theAddress, theStreet, theSeverity); } // set methods public void setDate( Date5 newDate) { date = newDate; } public void setAddress( int newAddress) { address = newAddress; } public void setStreet( String newStreet) { street = newStreet; } public void setSeverity( int newSeverity) { severity = newSeverity; } // toString method allows nicely formatted display of potHole in println public String toString() { return "Pothole #" + number + " reported " + date + ", at " + address + " " + street + ", severity " + severity; } // method closeBy determines whether or not addresses are close by, // which is true if the first two digits are the same public boolean closeBy( Pothole otherPothole) { // get 1st two digits of both potHole addresses int firstAddress = this.address / 100; int secondAddress = otherPothole.address / 100; // find the absolute value of the difference int difference = firstAddress - secondAddress; // return true if difference is 0, that is they are on same block if( difference == 0) { return true; } else { return false; } }//end method closeBy } //end class Pothole