Methapolis  0.27
 All Classes Namespaces Files Functions Variables Enumerator
CityLocation.java
Go to the documentation of this file.
1 // This file is part of MicropolisJ.
2 // Copyright (C) 2013 Jason Long
3 // Portions Copyright (C) 1989-2007 Electronic Arts Inc.
4 //
5 // MicropolisJ is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU GPLv3, with additional terms.
7 // See the README file, included in this distribution, for details.
8 
9 package micropolisj.engine;
10 
11 import java.io.Serializable;
12 
16 public class CityLocation implements Serializable
17 {
21  public int x;
22 
26  public int y;
27 
31  public CityLocation(int x, int y)
32  {
33  this.x = x;
34  this.y = y;
35  }
36 
37  @Override
38  public int hashCode()
39  {
40  return x*33+y;
41  }
42 
43  @Override
44  public boolean equals(Object obj)
45  {
46  if (obj instanceof CityLocation) {
47  CityLocation rhs = (CityLocation)obj;
48  return this.x == rhs.x && this.y == rhs.y;
49  }
50  else {
51  return false;
52  }
53  }
54 
55  @Override
56  public String toString()
57  {
58  return "("+x+","+y+")";
59  }
60 }