This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Need help understanding instructions for project. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Need help understanding instructions for project." Watch "Need help understanding instructions for project." New topic
Author

Need help understanding instructions for project.

Mack Grill
Greenhorn

Joined: Feb 27, 2012
Posts: 29
I'm creating an Applet that will display 3 houses but I am a little confused on how to the instructions want me to create this

instructions:

"write an Applet class named Construction.java. It should build 3 houses (rectangles with triangle roofs on top) but its paint method should be only 3 calls to a method named drawHouse.

In Construction.java, you should (at least) define methods named: paint (which invokes drawHouse), drawHouse (which invokes drawTriangle and probably methods from the Graphics class), and drawTriangle."

I'm confused on how to set up the paint() method to make only 3 calls to the drawHouse() method and also how to invoke drawTriangle() into drawHouse()

here is my code so far:


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I'm confused on how to set up the paint() method to make only 3 calls to the drawHouse() method

you have to draw 3 houses, don't you?
"It should build 3 houses (rectangles with triangle roofs on top)"

> how to invoke drawTriangle() into drawHouse()

same way you invoke drawHouse() from paint()

basically, you pass to drawHouse()
1) paint's graphic object
2) the location of the house
3) the width and height of the house.

2 and 3 could be combined to pass a Rectangle
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Don't ever call resize(...) or otherwise change the state of a Component in a painting method override.


luck, db
There are no new questions, but there may be new answers.
 
wood burning stoves
 
subject: Need help understanding instructions for project.
 
Similar Threads
Convert Applet to Stand-alone app
please help me with actionlistener
Koch Curve
Convert Applet to Stand-alone app
Virtual Graphing Calculator