i would like to multiply string by an interger value, for what im working on is a health system for a simple game. so what i did was made an ASCII heart and would like to take this away and add to this depending on what the players health is like.
String heart = " _ _ ";
String heart2 =" ( \/ )";
String heart3 =" \ / ";
String heart4 = " \/ ";
so to output the player health would be like:
System.out.println(heart*8);
System.out.println(heart2*8);
System.out.println(heart3*8);
System.out.println(heart4*8);
to equal an output like this
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ )
\ / \ / \ / \ / \ / \ / \ / \ /
\/ \/ \/ \/ \/ \/ \/ \/
and to take away a health id simply just multiply if by one less number,
System.out.println(heart*7);
System.out.println(heart2*7);
System.out.println(heart3*7);
System.out.println(heart4*7);
to have an output of
_ _ _ _ _ _ _ _ _ _ _ _ _ _
( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ ) ( \/ )
\ / \ / \ / \ / \ / \ / \ /
\/ \/ \/ \/ \/ \/ \/
but from what i'm doing nothing seems to be happening as you cannot multiply string this way, could someone please help me multiply this out. Thanks