File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -15,16 +15,18 @@ public class StaticArrayQueue implements Queue {
1515 private int size ;
1616
1717 /**
18- * Constructs a new Queue with a specified capacity.
18+ * Constructs a new queue with a specified capacity.
19+ *
20+ * @param capacity The maximum number of items that the queue can hold.
1921 */
20- public StaticArrayQueue (int size ) {
21- if (size < 1 ) {
22- throw new IllegalArgumentException ("Size must be at least 1" );
22+ public StaticArrayQueue (int capacity ) {
23+ if (capacity < 1 ) {
24+ throw new IllegalArgumentException ("Capacity must be at least 1" );
2325 }
24- data = new char [size ];
26+ data = new char [capacity ];
2527 front = 0 ;
2628 rear = -1 ;
27- this . size = 0 ;
29+ size = 0 ;
2830 }
2931
3032 /**
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ public class StaticArrayStack implements Stack {
1313 private int top ;
1414
1515 /**
16- * Constructor to initialize the stack with a given size.
16+ * Constructor to initialize the stack with a given capacity.
17+ *
18+ * @param capacity The maximum number of items that the stack can hold.
1719 */
18- public StaticArrayStack (int size ) {
19- if (size < 1 ) {
20- throw new IllegalArgumentException ("Size must be at least 1" );
20+ public StaticArrayStack (int capacity ) {
21+ if (capacity < 1 ) {
22+ throw new IllegalArgumentException ("Capacity must be at least 1" );
2123 }
22- data = new char [size ];
24+ data = new char [capacity ];
2325 top = -1 ;
2426 }
2527
You can’t perform that action at this time.
0 commit comments