-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
58 lines (50 loc) · 1.83 KB
/
Main.java
File metadata and controls
58 lines (50 loc) · 1.83 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
package stack1;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* Create a Stack class and Queue Class containing the following methods:
*
* Stack:
*
* push(int value) should insert an element in the top of stack and returns the new length
* push(int[] values) should insert array's elements into the stack and returns the new length
* pop() should remove the top element and return it
* pop(int elements) should remove number of elements given
*
* Queue:
*
* enqueue(int value) should insert an element in the top of stack and returns the new length
* enqueue(int[] values) should insert array's elements into the stack and returns the new length
* dequeue() should remove the top element and return it
* dequeue(int elements) should remove number of elements given
*
* common methods:
*
* dump(string separator) should print on console an string with all values separated by the provided separator, if not separator is defined then it should return separated by commas
* toArray() should return an array with all elements
* join(string separator) should return a string with all values separated by the provided separator, if not separator is defined then it should return separated by commas
* unique() returns all unique values, this means, the values which are not duplicated
*
* Unit tests of each method plz!@
*
* */
Stack mystack = new Stack();
Stack mystackA = new Stack(); //array
Queue myqueue = new Queue();
Queue myqueueA = new Queue();//array
mystack.push(1);
mystack.push(5);
mystack.push(6);
mystack.push(5);
mystack.push(6);
mystack.push(5);
mystack.push(6);
mystack.push(5);
mystack.push(2);
mystack.push(4);
mystack.push(6);
mystack.push(7);
mystack.unique();
}
}