-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resistor.cpp
71 lines (55 loc) · 1.39 KB
/
Resistor.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
#include "Resistor.h"
#include <string>
#include <iomanip>
Resistor::Resistor(){}
Resistor::Resistor(string name_, double resistance_, int endpoints_[]){
name = name_;
resistance = resistance_;
endpointNodeIDs[0] = endpoints_[0];
endpointNodeIDs[1] = endpoints_[1];
next = NULL, prev = NULL;
}
Resistor::~Resistor(){
delete next;
}
string Resistor::getName() const{
return name;
}
double Resistor::getResistance() const{
return resistance;
}
int* Resistor::getPoints(){
return endpointNodeIDs;
}
int Resistor::getP1(){
return endpointNodeIDs[0];
}
int Resistor::getP2(){
return endpointNodeIDs[1];
}
Resistor* Resistor::getNext(){
return next;
}
Resistor* Resistor::getPrev(){
return prev;
}
void Resistor::setResistance(double resistance_){
resistance = resistance_;
}
void Resistor::setName(string n){
name = n;
}
void Resistor::setEndPoints(int ep[2]){
endpointNodeIDs[0] = ep[0];
endpointNodeIDs[1] = ep[1];
}
void Resistor::setPrev(Resistor* prev_){
prev = prev_;
}
void Resistor::setNext(Resistor* next_){
next = next_;
}
void Resistor::print(){ //Proper formatting for printing a resistor
cout << left << setw(20) << name << " " << right << setw(8) << resistance <<
" Ohms " << endpointNodeIDs[0] << " -> " << endpointNodeIDs[1] << endl;
}