• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Applet drawing lines

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm new to java and having difficulty using graphics method combined with control structures

The task is to draw this image inside a rectangle. (10,10,980,640)
Is there a way to use two separate for loop to create this image?

If what I said above is incorrect. I'm guessing that write the control structure for the horizontal lines, then nest the for loop structure for the vertical line? Then alter the conditions.



Thanks
Screenshot-(345).png
[Thumbnail for Screenshot-(345).png]
 
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Nick, welcome to the Ranch!

I suppose there might be a way to use two separate for-loops. I mean, when I look at the picture it looks to me like there's two separate groups of lines, the big box on the outside and the small box on the inside. So maybe you could use one for-loop for the big box and another for-loop for the small box.

But why would you approach it that way? If it were me I would start by figuring out how to draw just one of the hundreds of lines which make up that picture (which I also have absolutely no idea how to do that). Then perhaps many of the lines differ by having one or two parameters which vary, and you could then write a loop to collect all of those lines together.

Anyway, I have to say that "How do I do this with two loops?" is not a question which would ever occur to me when trying to draw that picture.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic