-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipeConnector.java
More file actions
76 lines (61 loc) · 1.59 KB
/
PipeConnector.java
File metadata and controls
76 lines (61 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pipepuzzle;
import java.util.Collection;
import java.util.HashMap;
/**
*
* @author bLind
*/
class PipeConnector {
private Card card;
private int direction;
/**
* if the connectors card has a neighbour, this is the pipeConnectors
* adjacent pipeconnector
*/
private PipeConnector neighbour;
/**
* Maps from the pipeConnection to the corresponding pipe
*/
private HashMap<Integer, Pipe> pipes;
public PipeConnector(Card card, int direction) {
this.card = card;
this.direction = direction;
this.pipes = new HashMap<>();
}
public void removeNeighbour() {
this.neighbour.neighbour = null;
this.neighbour = null;
}
public void setNeighbour(PipeConnector neighbour) {
this.neighbour = neighbour;
neighbour.neighbour = this;
}
public PipeConnector getNeighbour() {
return neighbour;
}
public void addPipe(int pipeConnection, Pipe pipe) {
this.pipes.put(pipeConnection, pipe);
}
public Pipe getPipe(int pipeConnection) {
return this.pipes.get(pipeConnection);
}
public Card getCard() {
return card;
}
public void setCard(Card card) {
this.card = card;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public Collection<Pipe> getPipes() {
return this.pipes.values();
}
}