-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSavedPeer.java
75 lines (60 loc) · 1.59 KB
/
SavedPeer.java
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
import java.util.List;
import java.util.ArrayList;
public class SavedPeer {
private String username;
private String password;
private int countDownloads;
private int countFailures;
private List<SavedFile> files;
public SavedPeer(String username, String password) {
this.username = username;
this.password = password;
this.countDownloads = 0;
this.countFailures = 0;
this.files = new ArrayList<>();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getCountDownloads() {
return countDownloads;
}
public int getCountFailures() {
return countFailures;
}
public void incrementCountDownloads() {
countDownloads++;
}
public void incrementCountFailures() {
countFailures++;
}
public List<SavedFile> getFiles() {
return files;
}
public void setFiles(List<SavedFile> files) {
this.files = files;
}
public SavedFile getFile(String filename) {
for (SavedFile file : files) {
if (file.getFilename().equals(filename))
return file;
}
return null;
}
public void addFile(SavedFile file) {
if (!files.contains(file))
files.add(file);
}
public void removeFile(SavedFile file) {
files.remove(file);
}
}