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
797edb9b
Commit
797edb9b
authored
Mar 26, 2019
by
michael lundquist
Browse files
Adding a stest for the last search method.
parent
946daa09
Changes
2
Show whitespace changes
Inline
Side-by-side
fifthassignment/src/main/java/com/ds/fifthassignment/ArrayStack.java
View file @
797edb9b
...
...
@@ -37,13 +37,13 @@ public class ArrayStack {
*/
//TODO
public
int
search
(
Object
o
){
int
distance
=
1
;
//search for the element and increment distance
for
(
Object
cmp:
this
.
data
){
Object
cmp
;
for
(
int
distance
=
manyItems
-
1
,
counter
=
1
;
distance
>
0
;
distance
--,
counter
++){
cmp
=
this
.
data
[
distance
];
if
(
cmp
.
equals
(
o
)){
return
distance
;
return
counter
;
}
distance
++;
}
return
-
1
;
}
...
...
fifthassignment/src/test/java/com/ds/fifthassignment/AppTest.java
View file @
797edb9b
...
...
@@ -119,8 +119,9 @@ public class AppTest
}
}
JOptionPane
.
showMessageDialog
(
null
,
"the value of test is: "
+
(
11
-
test
)
);
JOptionPane
.
showMessageDialog
(
null
,
"The search result: "
+
s
.
search
(
"b"
));
assertTrue
(
s
.
search
(
"b"
)
==
(
11
-
test
));
int
ser
=
s
.
search
(
"b"
);
JOptionPane
.
showMessageDialog
(
null
,
"The search result: "
+
ser
);
assertTrue
(
ser
==
(
11
-
test
));
//assertTrue(false);
}
...
...
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