-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsland.cpp
More file actions
57 lines (48 loc) · 1.05 KB
/
Island.cpp
File metadata and controls
57 lines (48 loc) · 1.05 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
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include "proj6.h"
// default constructor for Island
Island::Island() {
nList = nullptr;
visit = false;
prev = -1;
}
// overloading =copyconstructor
Island& Island::operator=(const Island& other) {
if (this == &other) {
return *this;
}
if (this->nList != nullptr) {
nList->clear();
}
// deep copy =operator overload done in MyList.cpp
this->nList = other.nList;
this->visit = other.visit;
this->prev = other.prev;
return *this;
}
// add a MyList for Island
void Island::setnList(MyList* list) {
nList = list;
}
// set visited as true
void Island::visited() {
visit = true;
}
// set prev as given int that indicates prev island
void Island::setPrev(int prev) {
this->prev = prev;
}
// to access the adjacency list
MyList* Island::getnList() {
return nList;
}
// returns whether the island has been visited or not
bool Island::isVisited() {
return visit;
}
// returns which island we came from
int Island::getPrev() {
return prev;
}