-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.cpp
102 lines (80 loc) · 1.58 KB
/
Node.cpp
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
95
96
97
98
99
100
101
102
#include "Node.h"
#include "Resistor.h"
Node::Node(int id_){
id = id_;
voltage=0;
set=false;
next = NULL;
prev = NULL;
}
Node::Node(int id_, double voltage_, bool set_, Node *prev_, Node *next_){
id = id_;
voltage = voltage_;
set = set_;
prev = prev_;
next = next_;
}
Node::~Node(){
rl.clear();
delete next;
}
void Node::addResistor(Resistor* r){
rl.addResistor(r);
}
int Node::getID(){
return id;
}
Node* Node::getNext(){
return next;
}
Node* Node::getPrev(){
return prev;
}
void Node::setNext(Node* next_){
next = next_;
}
void Node::setPrev(Node* prev_){
prev = prev_;
}
void Node::setV(double voltage_){
voltage = voltage_;
}
void Node::forceSet(){
set = true;
}
void Node::unsetV(){
set = false;
voltage = 0;
}
bool Node::isSet(){
return set;
}
int* Node::getOtherNodes(){
return rl.getOtherNodes(id);
}
double* Node::getResistors(){
return rl.getResistors();
}
double Node::inverseSum(){
return rl.inverseSum();
}
double Node::getV(){
return voltage;
}
Resistor* Node::getR(string name){
return rl.getR(name);
}
double Node::modifyR(string name, double r){
Resistor* mod = getR(name);
double val = mod->getResistance();
mod->setResistance(r);
return val;
}
void Node::deleteR(string name){
rl.deleteR(name);
}
void Node::print(){
cout << "Connections at node " << id << ": "
<< rl.getSize() << " resistor(s)" << endl;
rl.printAll();
}