Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 9:22 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ]  Bookmark and Share
Author Message
 Post subject: problem with assignment
PostPosted: Wed Feb 06, 2008 9:55 am 
Offline

Joined: Fri Mar 02, 2007 1:50 pm
Posts: 5
Location: Sheffield, UK
Hi all i am currently doing an assignment and struggling like mad all i need to do is create a right angled triangle out of asterisks such as

*
**
***
****
*****

it has the size set to 5 and the orientation set to up all i need to know is how to get the public instance method called generate row to work correctly any help would be appreciated i am drowning i cannot get to grips with this at all.

the code for the method is below it should use a loop and concatenation to produce the triangle any help on this would be grateful.

import ou.*;

/**
* Class Triangle - instances model triangles as rows of asterisks
*
* M255 Course Team
* Version 1.0
*/
public class Triangle
{
/* instance variables */
int size; // the size of the triangle; an integer between 2 and 10 inclusive
String orientation; // either "up" or "down"
String asterisk;

/**
* Constructor for objects of class Triangle.
*/
public Triangle()
{
super();
this.size = 5;
this.orientation = "up";


}



/* instance methods */

/**
* Return the orientation of the triangle.
*/
public String getOrientation()
{
return this.orientation;
}

/**
* Return the size of the triangle.
*/
public int getSize()
{
return this.size;
}

/**
* Generates a row of Asterisks
*/
public String generateRow()
{
asterisk = "";
aSize = Integer.parseInt(return this.size);
for (int num = 1; num <= asize; num++)

asterisk = asterisk + "*";

System.out.prinln(asterisk);
}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley