• Post Reply Bookmark Topic Watch Topic
  • New Topic

Building a House in Java  RSS feed

 
John Jacksons
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have the following problem: "Make a new project: java1_Project10.
In it, 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.

When finished, hand in your java1_Project10."

I have the following code:




Could anyone advise me how to proceed? I am a little stuck here and any help would be appreciated.

 
Raymond Tong
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Construction should (at least) defined methods
1) paint (which invoke drawHouse)
2) drawHouse (which invoke drawTraingle + methods in Graphics class)
3) drawTriangle

Instruction from requirement
a) paint method should only 3 calls to drawHouse
b) house is rectangle with triangle roof on top

You drawHouse didn't invoke drawTriangle
paint method didn't have 3 calls to drawHouse

Think about why you should have 3 calls to drawHouse not 2 nor 4.
Think about why drawHouse should invoke drawTriangle + methods in Graphics class
 
John Jacksons
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Could you provide me with an example or something? I'm really sorry, but I'm quite new to Java! Thank you again!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!