1b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov/**
211a89b445f3bde56bf07e6a0d04f0b0256dcb215Andrey Somov * Copyright (c) 2008, http://www.snakeyaml.org
3b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
4b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * Licensed under the Apache License, Version 2.0 (the "License");
5b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * you may not use this file except in compliance with the License.
6b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * You may obtain a copy of the License at
7b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
8b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *     http://www.apache.org/licenses/LICENSE-2.0
9b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
10b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * Unless required by applicable law or agreed to in writing, software
11b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * distributed under the License is distributed on an "AS IS" BASIS,
12b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * See the License for the specific language governing permissions and
14b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * limitations under the License.
15b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov */
16b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somovpackage examples;
17b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
18b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somovpublic class Dice {
19b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    private Integer a;
20b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    private Integer b;
21b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
22b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public Dice(Integer a, Integer b) {
23b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        super();
24b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        this.a = a;
25b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        this.b = b;
26b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
27b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
28b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public Integer getA() {
29b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return a;
30b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
31b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
32b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public Integer getB() {
33b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return b;
34b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
35b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
36b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    @Override
37b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public boolean equals(Object obj) {
38b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        if (obj instanceof Dice) {
39b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov            return toString().equals(obj.toString());
40b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        }
41b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return false;
42b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
43b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
44b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    @Override
45b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public int hashCode() {
46b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return toString().hashCode();
47b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
48b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
49b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    @Override
50b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public String toString() {
51b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return "Dice " + a + "d" + b;
52b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
53b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov}
54