diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-11-23 13:51:12 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-11-23 13:51:12 -0500 |
| commit | 3c62b863509131e78c18ed13c6b83e4fc508848f (patch) | |
| tree | cf246e91da283edf704af936b9cef7eb8e09a6f8 /src/main/java/derms/replica/replica1/Resource.java | |
| parent | e3b72053e8b04f2df013da0d7d49fe33927461a9 (diff) | |
| download | soen423-3c62b863509131e78c18ed13c6b83e4fc508848f.zip | |
import replica code from assignment
Diffstat (limited to 'src/main/java/derms/replica/replica1/Resource.java')
| -rw-r--r-- | src/main/java/derms/replica/replica1/Resource.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/derms/replica/replica1/Resource.java b/src/main/java/derms/replica/replica1/Resource.java new file mode 100644 index 0000000..4abe41b --- /dev/null +++ b/src/main/java/derms/replica/replica1/Resource.java @@ -0,0 +1,39 @@ +package derms.replica.replica1; + +import java.io.Serializable; + +public class Resource implements Serializable { + public ResourceID id; + public ResourceName name; + public int duration; + public boolean isBorrowed; + public CoordinatorID borrower; + public int borrowDuration; + + public Resource(ResourceID id, ResourceName name, int duration, boolean isBorrowed, CoordinatorID borrower, int borrowDuration) { + this.id = id; + this.name = name; + this.duration = duration; + this.isBorrowed = isBorrowed; + this.borrower = borrower; + this.borrowDuration = borrowDuration; + } + + public Resource(ResourceID id, ResourceName name, int duration) { + this(id, name, duration, false, new CoordinatorID(), -1); + } + + public Resource() { + this(new ResourceID(), ResourceName.AMBULANCE, 0); + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public String toString() { + return id+" "+duration; + } +} |