-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageBox.java
More file actions
65 lines (61 loc) · 1.01 KB
/
StorageBox.java
File metadata and controls
65 lines (61 loc) · 1.01 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
58
59
60
61
62
63
64
import java.util.Arrays;
import java.util.ArrayList;
public class StorageBox
{
ArrayList<Object> box = new ArrayList<>();
private int max=5;
//construction
public void StorageBox()
{
}
//construction2
public void StorageBox(int max)
{
}
//IsEmpty
public void IsEmpty()
{
System.out.println(this.box.isEmpty());;
}
//len
public void len()
{
System.out.println(this.box.size());
}
//push
public void push(Object x)
{
this.box.add(x);
}
//tostring
public void tostring()
{
for (int i = 0; i < this.box.size() ; ++i)
{
System.out.print(this.box.get(i)+" ");
}
}
//IsFull
public boolean IsFull()
{
if (this.box.size() == max )
{
return true;
}
else
{
return false;
}
}
//pop
public void pop()
{
System.out.println(this.box.get(this.box.size()-1));
this.box.remove(this.box.size()-1);
}
//top
public void top()
{
System.out.println(this.box.get(this.box.size()-1));
}
}