The Artima Developer Community
Sponsored Link

Java Answers Forum
Rectangles in Java

4 replies on 1 page. Most recent reply: Sep 27, 2008 8:03 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
John Deere

Posts: 1
Nickname: toolbar
Registered: Sep, 2008

Rectangles in Java Posted: Sep 4, 2008 6:53 PM
Reply to this message Reply
Advertisement
Guys,

How would you make a method that creates a rectangle using the for loop? One that would make a blank rectangle which you can later call using the drawRect(int,int,int,int) function.


Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Rectangles in Java Posted: Sep 5, 2008 12:56 AM
Reply to this message Reply
September. Another school year starts...

The deal is that you show that you've done as much of your homework as you can, and people here will help you to understand and do the rest. Everyone here has better things to do than other people's homework for them.

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Rectangles in Java Posted: Sep 18, 2008 2:31 PM
Reply to this message Reply
You could pass an array of type int and then use a for loop to read each one. Maybe the forst two array element could be the upper left corner x and y, the last two the width and height.

Dave Lorde

Posts: 8
Nickname: dlorde
Registered: Aug, 2005

Re: Rectangles in Java Posted: Sep 27, 2008 1:58 AM
Reply to this message Reply
Just to be different, you could use the X,Y co-ordinates of two corners. Conventionally, one corner and height & width are used, but two corners works just as well.

Whichever way you do it with these parameters, using a for loop to draw a rectangle seems a bit of a stretch...

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Rectangles in Java Posted: Sep 27, 2008 8:03 AM
Reply to this message Reply
I'm with you about the for loop.
The original question seemed hokey plus there was no answer by the person who posted it. It appears to less than genuine.

It gets old seeing posts like "I'm new at java. What should I do." or "I need java to read "microsoft word" files or do "crystal reports". or "I have to write a program, how do I start."

They just drag things down to a halt.

This forum could use some moderation to dump these type of posts. It might be time to "weed the garden".

Flat View: This topic has 4 replies on 1 page
Topic: Unboxing or toString()? Previous Topic   Next Topic Topic: Run a java class within another class

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use