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 1b

 
Nath Maniedeo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi I'm having some trouble with Hundred B...like how do we check the console size for example...are they all the same?

My idea is to do a bunch of if loops to check the size of the name.

any help is appreciated.

thanks..
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nath Maniedeo:
how do we check the console size for example...are they all the same?
My idea is to do a bunch of if loops to check the size of the name.


Console sizes are not all the same. However, you should write your code so that the names will fit on an 80-character-size console (even if your console isn't 80 characters wide).

You can get the length of the name with one method call ... name.length()

Now you know the length of the name, and you know the length of the line in the console ... do a simple calculation to see how many names will fit on a line.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic