1 package org.drools.jsr94.benchmark;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 /*
7 $Id: Guest.java,v 1.1 2003/03/22 00:57:26 tdiesler Exp $
8
9 Copyright 2002 (C) The Werken Company. All Rights Reserved.
10
11 Redistribution and use of this software and associated documentation
12 ("Software"), with or without modification, are permitted provided
13 that the following conditions are met:
14
15 1. Redistributions of source code must retain copyright
16 statements and notices. Redistributions must also contain a
17 copy of this document.
18
19 2. Redistributions in binary form must reproduce the
20 above copyright notice, this list of conditions and the
21 following disclaimer in the documentation and/or other
22 materials provided with the distribution.
23
24 3. The name "drools" must not be used to endorse or promote
25 products derived from this Software without prior written
26 permission of The Werken Company. For written permission,
27 please contact bob@werken.com.
28
29 4. Products derived from this Software may not be called "drools"
30 nor may "drools" appear in their names without prior written
31 permission of The Werken Company. "drools" is a registered
32 trademark of The Werken Company.
33
34 5. Due credit should be given to The Werken Company.
35 (http://drools.werken.com/).
36
37 THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
38 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
39 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
40 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
41 THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 OF THE POSSIBILITY OF SUCH DAMAGE.
49
50 */
51
52 public class Guest {
53 private String name;
54 private char sex;
55 private List hobbies;
56
57 public Guest(String name, char sex) {
58 this.name = name;
59 this.sex = sex;
60 this.hobbies = new ArrayList();
61 }
62
63 public void addHobby(String hobby) {
64 this.hobbies.add(hobby);
65 }
66
67 public String getName() {
68 return name;
69 }
70
71 public char getSex() {
72 return sex;
73 }
74
75 public List getHobbies() {
76 return hobbies;
77 }
78
79 public boolean hasOpositeSex(Guest guest) {
80 return sex != guest.sex;
81 }
82
83 public boolean hasSameHobby(Guest guest) {
84 boolean hobbyFound = false;
85 for (int i = 0; !hobbyFound && i < hobbies.size(); i++) {
86 String hobby = (String)hobbies.get(i);
87 hobbyFound = guest.hobbies.contains(hobby);
88 }
89 return hobbyFound;
90 }
91
92 public String toString() {
93 return "{name=" + name + ",sex=" + sex + ",hobbies=" + hobbies + "}";
94
95 }
96 }
This page was automatically generated by Maven