LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-23-2004, 01:30 AM   #1
007spy
LQ Newbie
 
Registered: Jan 2004
Posts: 4

Rep: Reputation: 0
Need JAVA expert HELP!


any JAVA expert can help me out?

write two java programs.

The first program should draw a single red triangle in the center of a 300 x 300 pixel Frame.


The second program should allow the user to pass the number of triangles to be drawn in a 300 x 300 pixel Frame as a command line argument. You are free to arrange the triangles in any way you like e.g. top down, left right, etc…


thanx very much!!!!
 
Old 01-23-2004, 06:15 AM   #2
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 48
what aspect of this do you need help with?
 
Old 01-23-2004, 12:03 PM   #3
Astro
Member
 
Registered: Jan 2003
Location: Ballston Lake, NY
Distribution: Slackware, Debian
Posts: 660

Rep: Reputation: 30
Sounds like a homework question to me
 
Old 01-23-2004, 12:43 PM   #4
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
Yes, what exactly are you have problems with?
 
Old 01-23-2004, 06:07 PM   #5
007spy
LQ Newbie
 
Registered: Jan 2004
Posts: 4

Original Poster
Rep: Reputation: 0
i want the entire codes for programming these two classes.
By the way, u guys r absolutely right, and this is sort of an assignment of mine.
 
Old 01-23-2004, 06:08 PM   #6
007spy
LQ Newbie
 
Registered: Jan 2004
Posts: 4

Original Poster
Rep: Reputation: 0
thanx very much in advance.
 
Old 01-23-2004, 06:13 PM   #7
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
You'll have to realize that nobody here has the interest in doing an assignment for you. We WILL help you out if you are having specific problems making something work. So ask the right kind of questions and you'll get the answers you need.

Start writing the code and let us know what you are having problems with.
 
Old 01-23-2004, 06:25 PM   #8
007spy
LQ Newbie
 
Registered: Jan 2004
Posts: 4

Original Poster
Rep: Reputation: 0
wel... ok. anyway thanx 4 comment
i am actually trying to do this right now,but i have no idea how to get started.

here is what i've done so far:as follows
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class DrawTriangles extends Applet
{
private Graphics g;
private Triangle redTriangle;

public void init ()
{
g = getGraphics ();
addMouseListener (new PointListener ());
} // method init

// PointListener is an inner class that listens for the mouse to be pressed.
class PointListener implements MouseListener
{
public void mousePressed (MouseEvent e)
{
int xval, yval;
xval = e.getX ();
yval = e.getY ();
redTriangle = new Triangle (Color.red, xval, yval);
redTriangle.drawTriangle (g);
} // mousePressed

public void mouseEntered (MouseEvent e) {}
public void mouseExited (MouseEvent e) {}
public void mouseReleased (MouseEvent e) {}
public void mouseClicked (MouseEvent e) {}
} // class PointListener
} // class DrawTriangles

// Triangle draws triangles wherever the mouse has been pressed.
class Triangle
{
private int x, y;
private Polygon poly;
private Color color;

Triangle (Color c, int xPosition, int yPosition)
{
color = c;
x = xPosition;
y = yPosition;
} // constructor

/* drawTriangle creates two lists of points centered around x and y.
It then creates a new polygon and draws it. */
public void drawTriangle (Graphics g)
{
g.setColor (color);
int [] xList = {x-20, x, x+20};
int [] yList = {y, y-20, y};
poly = new Polygon (xList, yList, 3);
g.fillPolygon (poly);
} // method drawTriangle
} // class Triangle
public static void main(String args[]) {

Applet applet = new Triangle();
applet.setSize(300, 300);
applet.show();
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need an expert BookMaker Linux - Newbie 6 07-09-2005 08:03 PM
Begineer.....Help Me Get Expert muazzam Red Hat 2 02-18-2005 07:47 PM
need an expert for this one jjd228 Linux - Software 22 08-19-2004 12:51 AM
I need the help of a Backup EXpert !!! Vendetta Linux - Newbie 1 01-21-2002 07:23 PM
Expert Please eckomark Linux - Newbie 6 11-11-2001 12:06 AM


All times are GMT -5. The time now is 05:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration