• 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

printing 2 lines and going back to the previous line to print some more

 
Ranch Hand
Posts: 179
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

the subject might be misleading but i have the following question.

I was actually trying to implement the bowling scenario in java and have the following problem with print statement.

the output should be in the following format.

12 13 X 4/ 24 11 45

3 7 27 39 45 47 56

My problem is i need to print as soon as each of the ball is rolled.

so i should be printing "12" first then print 3 then go back to the previous line and then print "13".

I dont think the regular println statement will work.

Can you guys help me out..

Thanks,
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds more like a beginner's question to me . . .

Show us what you are doing. Maybe creating lines rather than printing individual numbers would work better.
 
Ravikanth kolli
Ranch Hand
Posts: 179
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, i am actually not sure..

i got stuck in the point of printing values in the lines..
I was told to have the numbers displayed after each bowl which means we need to have the values printed in each line.

Is there any way where i can change lines during my print statement
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could easily do that with text components on a Swing interface with the append method.
You can use the \b escape which sometimes goes backwards but only on a single line.
You can go through the JavaRanch FAQ; it tells you somewhere how to clear a command-line or terminal window, but that might entail using Runtime.exec() (then you can print the two lines on a clear screen).

But I don't know any way to go back to a preceding line.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic