Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filling Array

 
Teri Fisher
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write the test code in Main and don't understand how to fill my array with the methods we are supposed to use. Thanks in advance.

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's 465 lines of code!

Can you focus on a few lines and tell us where exactly you're having trouble?
 
Teri Fisher
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I guess I wanted to show what I had to work with, I wanted to put in an add method but we are supposed to use what is in our outline.
 
Henry Wong
author
Marshal
Pie
Posts: 20820
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to put in an add method but we are supposed to use what is in our outline.


Basically, you are writing test code. If you modify your class with special methods just for your test code, aren't you just wasting a testing opportunity?

Your class seems to have two add methods that add individual elements -- addBefore and addAfter. Do they work correctly? Have you tested them? If you have tested them, I am assuming that you wrote a loop that load them up? And if you did, can you reuse that testing code here?

Henry
 
Teri Fisher
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that's my problem, I was trying to use my addAfter in my test code to get started but was unsuccessful. Once I get going with my array I think I'll be fine, I think that I confuse myself with my variables and I'm stuck.
 
Teri Fisher
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am narrowing it down to my addAfter and addBefore methods now that they are fixed (I think), my question is about the outputs. I know it is still too much code but I am not understanding my output--
1)Why is the addBefore order reversed and why does the list for test 1 not display 9 from the addAfter?
2)Why are there three sets of zeros at the end of the double list?

 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic