• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Still stuck on 1.4

 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marilyn, most of your last comments I can agree with and I will make those changes and resend, but there is one question I was hoping to get others opinions.


Do you think that working with an integer would be more difficult than working with a string?


This comes from me converting the argument passed in from a string to an array of ints.
I think working with integers would be easier because I think it is more intuitive, since the problem we are dealing with here involves numbers, but I also think that comparing two primitive values would be more efficient than comparing the values of two strings. That was my thinking of turning the string into an integer.
Bill
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is reasonable to assume that comparing two primitives would be more efficient than comparing two Strings. I've just started looking at this assignment (I have to make one small change to 1.3 and resubmit ) so I can't really say more.
John
 
Trailboss
Posts: 23778
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For some cattle drive folks I add the requirement that I want them to make a method that introduces some abstraction. The method will take and integer and the value must be in the range of 0 to 999. It will then "say" that value.
If you have such a method, writing your main becomes much easier. From within this new method, your task becomes much easier. The whole program falls together.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I have such a method. I passed in three single digit integers but the same theory as what you are saying I believe. Does make the whole program easier. What I was getting from Marilyn quote though was that she would rather me use a String than integers.
I have some cleaning to do, so I will do that and submit again.
Bill
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"You already converted it to an integer, but you pass in the string only to have the string converted to integers. Do you think that working with an integer would be more difficult than working with a string?"

Read: "... Do you think that passing an integer would be more difficult than passing a string?"

[This message has been edited by Marilyn deQueiroz (edited January 25, 2001).]
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Marilyn, I see where you are getting at now
The reason I passed the String was so that I could add a "0" or a "00" to the beginning of it to always make it divisible by three. Then I could loop through them three at a time after I make that string into an array of single digit ints.
I think what you and Paul are getting at is to instead of doing any of that above, is convert to a number and then pass the number. Then just do divide by a billion, a million, a thousand to get the three digits to work with.
If that is the case, I will have worked this thing three ways. First I reversed the string and placed it into an array of ints, then I went through the string forward but still placed them into an array of ints, and (hopefully) finally I moved forward without using an array at all. I'm slowly getting it
Bill
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried a few different ways myself before getting to a good solution.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
I just submitted 1.4 ... haven't been nitpicked yet ... but it took me four re-writes to get something I was happy with ... I'm hoping it won't take another 4 to get it by the nitpick 'cause I've already pulled out most of my hair
Jane
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank goodness I wasn't the only one. I just submitted my 5th try. I'll have to say though, thanks Marilyn. My code has become more clear and more concise with each revision. I started off with like 150 lines of code and now I am down to 115, plus it is much easier to follow. So thanks for frustrating me like crazy, but also forcing me to think a little more before I write.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic