diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-11-28 10:42:31 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-11-28 10:42:31 -0500 |
| commit | 6a710c3943f2350f4575f8cb1898129ef3c7dfdd (patch) | |
| tree | dc20bc0480e77a74f2176e5f0fed02ad2251a2cd /src/main/java/derms/replica/replica1/ResourceID.java | |
| parent | 0cae203edc71b0285d2971f9124f24cb543b8e39 (diff) | |
| download | soen423-6a710c3943f2350f4575f8cb1898129ef3c7dfdd.zip | |
rename assignment code replica package
Diffstat (limited to 'src/main/java/derms/replica/replica1/ResourceID.java')
| -rw-r--r-- | src/main/java/derms/replica/replica1/ResourceID.java | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/main/java/derms/replica/replica1/ResourceID.java b/src/main/java/derms/replica/replica1/ResourceID.java deleted file mode 100644 index 008b766..0000000 --- a/src/main/java/derms/replica/replica1/ResourceID.java +++ /dev/null @@ -1,49 +0,0 @@ -package derms.replica.replica1; - -import java.io.Serializable; - -public class ResourceID implements Serializable { - public String city; - public short num; - - public ResourceID (String city, short num) { - this.city = city; - this.num = num; - } - - public ResourceID() { - this("XXX", (short) 1111); - } - - public static ResourceID parse(String s) throws IllegalArgumentException { - if (s.length() != City.codeLen+ID.nDigits) { - throw new IllegalArgumentException("invalid resource ID: "+s); - } - try { - String cityCode = s.substring(0, City.codeLen); - short num = Short.parseShort(s.substring(City.codeLen)); - return new ResourceID(cityCode, num); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("invalid resource ID: "+e.getMessage()); - } - } - - @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != this.getClass()) { - return false; - } - ResourceID other = (ResourceID) obj; - return (this.city.equals(other.city)) && (this.num == other.num); - } - - @Override - public int hashCode() { - return city.hashCode() * num; - } - - @Override - public String toString() { - return city+num; - } -} |