Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assignment 1.1 - OS specific?

 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marilyn,
In my Assignment 1.1 nitpick there is the following comment :
Looks like you are depending on something that the operating system does. I suggest that, instead, you simply avoid the 80th character and always force a new line at the end of each line

I believe it is about this line :

I've looked in the API reference and I can't seem to fine any way to get the current line width of the system...
Can you give me any more hints on what to do?
Thanks,
-Nate

[This message has been edited by Nathan Pruett (edited January 31, 2001).]
 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Marilyn,

i too got a similar comment on my assignment 1.1 (depending on the behaviour of one particular OS). What do u mean by 'avoid the 80th character' ?
Also, do i have to take care of 'divide by zero' that i get if the word is 78 / 79 characters long ?
regards,
soumya.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathan Pruett:
I've looked in the API reference and I can't seem to fine any way to get the current line width of the system...


Assume that there are 80 characters per line. Don't depend on an automatic word wrap that may occur with one OS. Figure out how many words will fit on a line in advance and force a new line each time you print that many words.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by soumya ravindranath:
i too got a similar comment on my assignment 1.1 (depending on the behaviour of one particular OS). What do u mean by 'avoid the 80th character' ?
Also, do i have to take care of 'divide by zero' that i get if the word is 78 / 79 characters long ?

Make sure the last word in your line does not write to the 80th column, because in some systems you will print an extra blank line if you do.

You can assume the word will not be any longer than 30 characters. Do you know someone with a name that is 78 characters long?
 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Is it ok to keep posting the assignment everyday with the changes or is it better to check out on this forum, get doubts clarified and make less no. of emailing to u, Marilyn ? (because i am some 6-10 hrs. ahead of u, i have to wait for at least two days before i can make the next submission. ( and at the rate it's going, i donno if i will reach the second assignment in the near future )
thanq,
soumya.
[This message has been edited by soumya ravindranath (edited February 01, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's better to post your questions in the forum. Even if you send me more than one email per day, I'm only going to look at one. So send me your best one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic