-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
54 lines (41 loc) · 2.13 KB
/
Main.java
File metadata and controls
54 lines (41 loc) · 2.13 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
public class Main {
public static void main(String[] args) {
WebPageStack webPageStack = new WebPageStack();
// Adding web pages to the stack
webPageStack.addWebPage(new WebPage("https://www.google.com/page1", "2023-07-22 10:30:00"));
webPageStack.addWebPage(new WebPage("https://www.youtube.com/page1", "2023-07-22 11:30:00"));
webPageStack.addWebPage(new WebPage("https://www.microsoft.com/page2", "2023-07-22 10:25:00"));
webPageStack.addWebPage(new WebPage("https://www.jdoodle.com/page3", "2023-07-22 10:35:00"));
webPageStack.addWebPage(new WebPage("https://www.amazon.com/page4", "2023-07-22 11:45:00"));
webPageStack.addWebPage(new WebPage("https://www.shein.com/page5", "2023-07-22 12:00:00"));
// Printing the most recent web page without removing it
WebPage mostRecentPage = webPageStack.peekMostRecentWebPage();
if (mostRecentPage != null) {
System.out.println("Most recent web page:");
System.out.println("URL: " + mostRecentPage.url);
System.out.println("Timestamp: " + mostRecentPage.timestamp);
} else {
System.out.println("The stack is empty.");
}
// Removing the most recent web page
WebPage removedPage = webPageStack.removeMostRecentWebPage();
if (removedPage != null) {
System.out.println("Removed web page:");
System.out.println("URL: " + removedPage.url);
System.out.println("Timestamp: " + removedPage.timestamp);
} else {
System.out.println("The stack is empty.");
}
// Printing the most recent web page after removal
mostRecentPage = webPageStack.peekMostRecentWebPage();
if (mostRecentPage != null) {
System.out.println("Most recent web page:");
System.out.println("URL: " + mostRecentPage.url);
System.out.println("Timestamp: " + mostRecentPage.timestamp);
} else {
System.out.println("The stack is empty.");
}
// Checking if the stack is empty
System.out.println("Is stack empty? " + webPageStack.isEmpty());
}
}