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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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
329 views