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