Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 19 20 package org.polepos.framework; 21 22 23 public class TeamCar { 24 25 private final Team team; 26 private final Car car; 27 28 public TeamCar(Team team, Car car){ 29 this.team = team; 30 this.car = car; 31 } 32 33 @Override  34 public boolean equals(Object obj) { 35 if(obj==this) { 36 return true; 37 } 38 if(obj==null||obj.getClass()!=getClass()) { 39 return false; 40 } 41 TeamCar key=(TeamCar)obj; 42 return team.equals(key.team) && car.equals(key.car); 43 } 44 45 @Override  46 public int hashCode() { 47 return team.hashCode() + car.hashCode(); 48 } 49 50 public String toString(){ 51 return team.name() + "/" + car.name(); 52 } 53 54 public String name(){ 55 return team.name() + "/" + car.name(); 56 } 57 58 public String description(){ 59 if(team.website() != null){ 60 return team.description(); 61 } 62 return car.description(); 63 } 64 65 public Team getTeam(){ 66 return team; 67 } 68 69 public Car getCar(){ 70 return car; 71 } 72 73 public String website(){ 74 String webSite = team.website(); 75 if(webSite != null){ 76 return webSite; 77 } 78 return car.getWebsite(); 79 } 80 81 82 } 83
| Popular Tags
|