-
Notifications
You must be signed in to change notification settings - Fork 0
/
PokeNode
94 lines (85 loc) · 1.77 KB
/
PokeNode
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
*PokeNode A.7
*@author Nicholas Miyamoto-Pennywell
*@since 11/25/17
*/
public class PokeNode {
private Pokemon pokemon;
private int caught;
private PokeNode left;
private PokeNode right;
public PokeNode(Pokemon p, int numCaught, PokeNode lChild, PokeNode rChild) {
pokemon = p;
caught = numCaught;
left = lChild;
right = rChild;
}
/*
*getPokemon(returns the Pokemon in a given node)
*/
public Pokemon getPokemon() {
return pokemon;
}
/*
*getKey (Pokemon species number in a given node)
*/
public int getKey() {
return pokemon.getNumber();
}
/*
*getNumCaught (Number of Pokemon of similar species caught in a given node)
*/
public int getNumCaught() {
return caught;
}
/*
*increaseNumCaught (increases the value of the numCaught in a given node)
*/
public void increaseNumCaught() {
caught++;
}
/*
*decreaseNumCaught (decreases the value of the numCaught in a given node)
*/
public void decreaseNumCaught() {
if (caught == 0) {
throw new PokeException("No Pokemon to Trade");
} else if (caught >= 1) {
caught--;
}
}
/**
* Accessor method.
*
* @return the left child's address
*/
public PokeNode getLChild() {
return left;
}
/**
* Mutator method.
*
* @param LChildParameter
* is the left child's address
*/
public void setLChild(PokeNode lChild) {
left = lChild;
}
/**
* Accessor method.
*
* @return the right child's address
*/
public PokeNode getRChild() {
return right;
}
/**
* Mutator method.
*
* @param RChildParameter
* is the right child's address
*/
public void setRChild(PokeNode rChild) {
right = rChild;
}
} //Class