Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ASCII Art

807598Mar 5 2006 — edited Mar 5 2006
I'm having some problems writing code to print out some ASCII shapes, in particular a heart. I have part of the method to print the top part of the heart. ****** ****** (the heart peaks)
******* *******
********* *********

but I'm having problems completing the method to print this particular part out. I know I'm supposed to use loops but I don't know how to start.
Any help is appreciated!


private void printHeartPeaksBody( int i, int height, int width, int margin )
{

int sideGap = i - 1;
int peakGap = i;
int peakWidth = width - sideGap - sideGap - peakGap;
int eachPeakWidth = (int) ( peakWidth / 2.0 );
if( ( sideGap + eachPeakWidth + peakGap + eachPeakWidth + sideGap ) < width )
{
peakGap++;
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2006
Added on Mar 5 2006
1 comment
417 views