aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/BrowserState.java
blob: da21c41c55664de34bfaca5fcc3dedfc3a34b719 (plain) (blame)
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
package model;

import java.util.ArrayDeque;

// This BrowserState function collects the stateful portions of the browser into one modelable class.
public class BrowserState {
    private ArrayDeque<String> tabs;
    private String currentTab;

    // EFFECTS: constructs a new BrowserState
    // MODIFIES: this
    public BrowserState(ArrayDeque<String> tabs, String currentTab) {
        this.tabs = tabs;
        this.currentTab = currentTab;
    }

    public ArrayDeque<String> getTabs() {
        return this.tabs;
    }

    public String getCurrentTab() {
        return this.currentTab;
    }

    // MODIFIES: this
    // EFFECTS: Sets the current tab
    public void setCurrentTab(String tab) {
        this.currentTab = tab;
    }

    // MODIFIES: this
    // EFFECTS: add a new tab
    public void addTab(String added) {
        if (!this.tabs.contains(added)) {
            this.tabs.add(added);
        }
    }

    // MODIFIES: this
    // EFFECTS: removes a tab from the tablist
    public void removeTab(String removed) {
        this.tabs.remove(removed);
    }
}