Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
306
306Ass5
Commits
e0b21e2c
Commit
e0b21e2c
authored
Mar 25, 2019
by
michael lundquist
Browse files
Adding untested code for the required methods. Now I need to test these methods.
parent
178073fd
Changes
4
Show whitespace changes
Inline
Side-by-side
fifthassignment/src/main/java/com/ds/fifthassignment/ArrayQueue.java
View file @
e0b21e2c
...
...
@@ -100,7 +100,11 @@ public class ArrayQueue {
*/
//TODO write this
public
boolean
offer
(
Object
e
){
if
(
manyItems
>=
data
.
length
){
return
false
;
}
this
.
add
(
e
);
return
true
;
}
}
\ No newline at end of file
fifthassignment/src/main/java/com/ds/fifthassignment/ArrayStack.java
View file @
e0b21e2c
...
...
@@ -39,11 +39,13 @@ public class ArrayStack {
public
int
search
(
Object
o
){
int
distance
=
1
;
//search for the element and increment distance
if
(
distance
<=
data
.
size
()){
for
(
Object
cmp:
this
.
data
){
if
(
cmp
.
equals
(
o
)){
return
distance
;
}
else
{
return
-
1
;
}
distance
++;
}
return
-
1
;
}
...
...
fifthassignment/src/main/java/com/ds/fifthassignment/LinkedListStack.java
View file @
e0b21e2c
...
...
@@ -67,14 +67,18 @@ public class LinkedListStack implements Iterable{
*/
//TODO make sure this works
public
int
search
(
Object
o
){
int
distance
=
1
;
int
distance
=
0
;
//search for the element and increment distance
if
(
distance
<=
data
.
size
()){
Iterator
it
=
this
.
iterator
();
Object
testObject
=
null
;
while
(
it
.
hasNext
()){
distance
++;
if
(
it
.
next
().
equals
(
o
)){
return
distance
;
}
else
{
return
-
1
;
}
}
return
-
1
;
}
public
boolean
isEmpty
()
{
return
(
top
==
null
?
true
:
false
);
...
...
fifthassignment/src/main/java/com/ds/fifthassignment/Stack.java
View file @
e0b21e2c
...
...
@@ -67,11 +67,15 @@ public class Stack {
public
int
search
(
Object
o
){
int
distance
=
1
;
//search for the element and increment distance
if
(
distance
<=
data
.
size
()){
Node
test
=
this
.
top
;
while
(
test
!=
null
){
if
(
test
.
data
.
equals
(
o
)){
return
distance
;
}
else
{
return
-
1
;
}
distance
++;
test
=
test
.
getNext
();
}
return
-
1
;
}
public
Object
pop
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment