java - How to properly update a line of text -
I am trying to create a basic non-static line of text that does not automatically reprint but \ R
either is not working or I am doing it wrong; I'm a very new person for Java so I'm sorry if the answer is really clear. Here is my code:
import java.util.Scanner; Public class textfoit {public static zero principal (string agre []) {int monetary strength = 10; Int YourHealth = 15; While {true} {System.out.println ("............"); System.out.print ("\ r ............"); System.out.println ("| |"); System.out.print ("\ r | |"); System.out.println ("| 0 0 |"); System.out.print ("\ r | 0 0 |"); System.out.println ("| ------- |"); System.out.print ("\ r | ------- |"); Println ("............"); System.out.print ("\ r ............"); Println (MonsterHealth); System.out.print ("\ r" + MonsterHealth); Println (""); Println (""); Println ("............"); System.out.print ("\ r ............"); System.out.println ("| |"); System.out.print ("\ r | |"); System.out.println ("| 0 0 |"); System.out.print ("\ r | 0 0 |"); System.out.println ("| ------- |"); System.out.print ("\ r | ------- |"); Println ("............"); System.out.print ("\ r ............"); Println (""); Println (YourHealth); System.out.print ("\ r" + Your Health); }}}
What this is doing:
15 ......... ... ............ | | | || 0 0 | | 0 || 0 || ------- | | ------- | ............ ............ 10 10 ............ ........ | | | || 0 0 | | 0 || 0 || ------- | | ------- | ............ ............ 15 15 ............ ........ | | | || 0 0 | | 0 || 0 || ------- | | ------- | ............ ............ 10
Please give me an example of the code again I am starting one .
If you want each piece on a new line, you will see Println
Instead of print
:
System.out.println ("............"); Println ("............"); System.out.println ("| |"); System.out.println ("| |"); System.out.println ("| 0 0 |"); ...
or "\ n"
and add a newline character and use print
:
System.out.print ("\ n ............"); System.out.print ("\ n ............"); ...
Comments
Post a Comment