Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Need help with drawing a house for AP Computer Science class

Thread view: 
ShakeN'Bake - 05 Sep 2006 00:26 GMT
Here is some code I found:

import apcslib.*;

public class DrawHouse
{
public static void main(String[] args)
{

DrawingTool pencil;
SketchPad paper;

paper= new SketchPad(500, 500);
pencil= new DrawingTool(paper);

pencil.turnLeft(90);
pencil.forward(50);
pencil.turnLeft(90);
pencil.forward(150);
pencil.turnLeft(90);
pencil.forward(100);
pencil.turnLeft(90);
pencil.forward(150);
pencil.turnLeft(90);
pencil.forward(100);
pencil.turnLeft(90);
pencil.forward(150);
pencil.turnLeft(90);
pencil.forward(250);
pencil.turnLeft(90);
pencil.forward(300);
pencil.turnLeft(90);
pencil.forward(400);
pencil.turnLeft(90);
pencil.forward(300);
pencil.turnLeft(90);
pencil.forward(400);
pencil.turnLeft(90);
pencil.forward(300);
pencil.turnLeft(75.964);
pencil.forward(206.155);
pencil.turnLeft(28.032);
pencil.forward(206.155);

}
}

I don't understand why there are decimal points in the last, third to
last, and fourth to last answers. Can someone please explain them to
me??
ShakeN'Bake - 05 Sep 2006 00:29 GMT
Another thing. Can someone give me a brief tutorial on drawing simple
things like houses or hexagons and circles?? Thanks.

> Here is some code I found:
>
[quoted text clipped - 46 lines]
> last, and fourth to last answers. Can someone please explain them to
> me??
Patricia Shanahan - 05 Sep 2006 00:56 GMT
> Here is some code I found:
...
> I don't understand why there are decimal points in the last, third to
> last, and fourth to last answers. Can someone please explain them to
> me??

I'd look at it the other way round. Why do you feel there should not be
any decimal points?

For a problem like this, I'd get myself a large piece of paper, a
pencil, a ruler, and a protractor, and pretend to be the computer. Start
in the middle of the paper, and use a scale that will allow you to go a
few hundred units in any direction without reaching an edge.

Is apcslib a library you are allowed to use?

Patricia
Oliver Wong - 05 Sep 2006 22:20 GMT
>> Here is some code I found:
[small portion of code unsnipped]
DrawingTool pencil;
SketchPad paper;

paper= new SketchPad(500, 500);
pencil= new DrawingTool(paper);

pencil.turnLeft(90);
pencil.forward(50);

[...]

pencil.turnLeft(75.964);
pencil.forward(206.155);
pencil.turnLeft(28.032);
pencil.forward(206.155);

[/small portion of code unsnipped]
>> I don't understand why there are decimal points in the last, third to
>> last, and fourth to last answers. Can someone please explain them to
>> me??

   Do you understand why there are decimals in the second to last statement
then? Can you explain what your theory is?

> I'd look at it the other way round. Why do you feel there should not be
> any decimal points?
[quoted text clipped - 3 lines]
> in the middle of the paper, and use a scale that will allow you to go a
> few hundred units in any direction without reaching an edge.

   Or perhaps get a piece of paper which is exactly 500 units wide and 500
units tall, and read the documentation to find out what happens when the
pencil leaves the edge of the paper (in case it does something non-obvious,
like wrap around on the other side)! Might be a good idea to find out what
the starting coordinate and facing of the pencil is too.

   - Oliver
Bill Medland - 05 Sep 2006 23:46 GMT
> Here is some code I found:
>
[quoted text clipped - 46 lines]
> last, and fourth to last answers. Can someone please explain them to
> me??
(Are you sure the last but one wasn't 28.072?)

Because the author wanted the roof to be 50 units tall
Signature

Bill Medland



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.