1 19 20 package org.cdmodule; 21 22 23 24 28 public class CD { 29 30 String artist; 31 String album; 32 33 public CD() { 34 artist = "N/A"; 35 album = "N/A"; 36 } 37 38 public CD(String ar, String al) { 39 artist = ar; 40 album = al; 41 } 42 43 public static CD createDefault() { 44 return new CD("Peter Graham", "Der Erste"); 45 } 46 47 public boolean equals(Object o) { 48 if (!(o instanceof CD)) { 49 return false; 50 } 51 CD d = (CD)o; 52 return artist.equals(d.artist) && 53 album.equals(d.album); 54 } 55 56 public int hashCode() { 57 return 125; 59 } 60 61 public String toString() { 62 return "CD[artist="+artist+", album="+album+"]"+super.toString(); 63 } 64 65 } 66 | Popular Tags |