KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > polepos > framework > TeamCar


1 /*
2 This file is part of the PolePosition database benchmark
3 http://www.polepos.org
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA. */

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 JavaDoc
34     public boolean equals(Object JavaDoc 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 JavaDoc
46     public int hashCode() {
47         return team.hashCode() + car.hashCode();
48     }
49     
50     public String JavaDoc toString(){
51         return team.name() + "/" + car.name();
52     }
53     
54     public String JavaDoc name(){
55         return team.name() + "/" + car.name();
56     }
57     
58     public String JavaDoc 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 JavaDoc website(){
74         String JavaDoc webSite = team.website();
75         if(webSite != null){
76             return webSite;
77         }
78         return car.getWebsite();
79     }
80
81     
82 }
83
Popular Tags