-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotebook.java
More file actions
37 lines (30 loc) · 782 Bytes
/
Notebook.java
File metadata and controls
37 lines (30 loc) · 782 Bytes
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
import java.util.*;
public class Notebook {
private static int idCounter = 1;
private int notebookId;
private String name;
private List<Note> notes;
public Notebook(String name) {
this.notebookId = idCounter++;
this.name = name;
this.notes = new ArrayList<>();
}
public void addNote(Note note) {
notes.add(note);
}
public void removeNote(int noteId) {
notes.removeIf(n -> n.getNoteId() == noteId);
}
public int getNotebookId() {
return notebookId;
}
public List<Note> getNotes() {
return notes;
}
public String getName() {
return name;
}
public void setName(String newName) {
this.name = newName;
}
}