/** Sample Answer for 11S E01 Exam. Note lack of javadoc comments---those were not required on the exam. */ public class RadioStation { private String callSign = "KCSB"; // b private double freq = 99.9; // b public RadioStation() {} ; // c public RadioStation(String callSign, double freq) { //d this.callSign = callSign; this.freq = freq; } public String getCallSign() { return callSign; } //e public double getFrequency() { return freq; } //e public boolean isFM() { return this.freq <= 108.0; } public String toString() { return "[" + this.callSign + ", " + (this.isFM() ? "FM " : "AM ") + this.freq + "]"; } public static void main(String [] args) { // h RadioStation KJEE = new RadioStation("KJEE",92.9); RadioStation KCSB = new RadioStation(); System.out.println(KJEE); } // not part of answer to q1 // code for q2 public boolean equals(Object o) { double tol = 0.01; if (! (o instanceof RadioStation) ) return false; RadioStation other = (RadioStation) o; return (other.getCallSign().equals(this.getCallSign()) & Math.abs(other.getFrequency() - this.getFrequency()) < tol ); } }