PDA

View Full Version : Project 3.3


drindy
02-11-2009, 11:06 PM
In the book It says to use a he/she builder, build a person. For your person, define an object method named walkinSquare() that has a parameter named edgeLength.
When walkinSquare(dist) is set to your person, he or she should walk in a square with edges that are of each dist meters long. Make certain your person begins and ends at the same spot. When the person is done, have the person say the area and perimeter of the square.
I have the shebuilder walking the square but unable to get her to get her to say the last part.....
Any help would be great, as i am doing this for Intro to programming class.

DrJim
02-12-2009, 10:40 AM
Interesting solution - but a little off the edges of the square (which is probably a realistic simulation anyway).

For the perimeter and area of the square, you will have to get the size of the side of the square and then use the appropriate geometric formulas for the area and perimeter. You can do this first - as shown in the attached - and then also use these variables in the walking routines.

I also included a brief example of how to resize the square to get any (reasonable) side dimension you want.

drindy
02-13-2009, 10:22 AM
Hey thanks for getting back to me, Thats cool, but i need the he/she build to walk the square number that the user puts in the box, for example if the user puts in lets say 5, the he/she build needs to walk that distance then give the number that it gets to walk the 4 edges. But the teacher says that the he/she build can't walk and give the number but can move, which is sliding the 4 corners, why can't the he/she build walk and caulate the numbers from each edge?

DrJim
02-13-2009, 11:14 AM
I really don't know how to answer that - seems to me there is no problem with both walking and calculating at the same time.

Perhaps your teacher means that the "builder" walk methods take time as an input parameter and not a distance so you do need to use both the move and walk methods - but you already did that.

Afraid you'll have to ask your teacher for more help - say an example of what he means.

drindy
02-13-2009, 12:07 PM
The Handout states, "Project 3.3, Let the user designate the distance that your person is to walk. Since the walk method for the he/she builder does not let you specify a distance, you can use the move method instead. Code at least 2 methods: my_first_method and walkInSquare. Ask your user for the distance in the my_first_method method and pass it as an argument to the walkInSquare method. It's your choice as to which of your 2 mothods present the area and perimeter. You will probably have atleast 6 variables: the edgeLength, distance, area (string and number) and perimeter (sting and number), I don't get much time to sit and wait to talk to the teacher as she is helpping other people, So i thought i would ask here for help, as its easier since there is alot of people with experiance here..... Thanks for all your help.

DrJim
02-14-2009, 12:19 PM
Afraid you're just going to have to stand in line for your teacher. I really don't see any problem with your approach vs. the question.

drindy
02-14-2009, 09:56 PM
Oh ok, Hey is there anyway to just get her to walk a distance, that a user inputs a number to walk and she gives the length of that walk when she returns to the origanal postion from where she starts?

drindy
02-17-2009, 10:35 PM
I'll take that as a no, Ok thanks