Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pair {
- private int a;
- private int b;
- public Pair(int a, int b) {
- this.a = a;
- this.b = b;
- }
- @Override
- public boolean equals(Object obj) {
- boolean result = false;
- if(obj.getClass().equals(Pair.class) || obj.getClass().equals(ColoredPair.class)) {
- Pair objPair = (Pair) obj;
- if (this.a == objPair.a && this.b == objPair.b) {
- result = true;
- } else if (this.a == objPair.b) {
- result = true;
- } else if (this.b == objPair.a) {
- result = true;
- }
- }
- return result;
- }
- }
- class ColoredPair extends Pair {
- final private String color;
- public ColoredPair(int a, int b, String color) {
- super(a, b);
- this.color = color;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement