|
Revision 138, 2.2 kB
(checked in by tfelker2, 3 years ago)
|
Now you can name nodes
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
import java.io.*; |
|---|
| 7 |
import java.util.*; |
|---|
| 8 |
|
|---|
| 9 |
public abstract class Node implements Serializable { |
|---|
| 10 |
static final long serialVersionUID = 3897565286366276995L; |
|---|
| 11 |
Node(int id) { |
|---|
| 12 |
this.id = id; |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
Node(int id, String name, String description) { |
|---|
| 16 |
this.id = id; |
|---|
| 17 |
this.name = name; |
|---|
| 18 |
this.description = description; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
public abstract Cost computeHCost(Search s, Node previousNode); |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
public boolean equals(Object o) { |
|---|
| 30 |
return (o instanceof Node) && (((Node)o).id == id); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
public int hashCode() { |
|---|
| 34 |
return id; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
public String toString() { |
|---|
| 39 |
return "Node\n" + infoToString(); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
public String infoToString() { |
|---|
| 43 |
return "\tid=" + id + "\n\tname=" + name + "\n\tdescription=" + description + "\n"; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { |
|---|
| 47 |
in.defaultReadObject(); |
|---|
| 48 |
edges = new LinkedList(); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
public void setDescription(String desc) { description = desc; } |
|---|
| 52 |
public String getDescription() { return description; } |
|---|
| 53 |
|
|---|
| 54 |
public String getName() { return name; } |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
public void setName(String s) { |
|---|
| 59 |
name = s; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
public boolean isOnMap(BackgroundMap m) { |
|---|
| 64 |
return true; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
public final int id; |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
private String name = ""; |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
private String description = ""; |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
public transient Collection edges = new LinkedList(); |
|---|
| 81 |
} |
|---|