View Single Post
Chicken Square
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default Chicken Square - 11-18-2015, 03:48 PM

Quote:
Originally Posted by LebronJames View Post
I even woke up before class to speak with my professor during his office hours which he was busy with registering students for next semester so I completed what I could but became very lost from there. I will Highlight what I have completed so far in my Alice world. The info that is Bold are the Questions I need help with but I attached my world work I have so far for you to inspect.

1) Place a chicken in the world. Create a method named chickenSquare that takes a parameter named size to indicate the size of the square. Using a loop, have the chicken move in a square where all movement is ‘forward’ (so the chicken will need to turn). Next create a method named chickenManySquares that takes a numeric parameters count and size. It then uses chickenSquare to make the chicken move in count number of squares of the given size. If the count isn’t valid (because it is negative) then the method should do nothing.

2) Write a method named findRem5. It asks the user for two numbers start and end. End must be > start and if it isn’t, the program should continue asking the user for a value until end is > start. It then counts up starting from start to end by ones printing each value. In addition to printing the number, if that number is divisible by 5 it should print an * beside it. For example, if start was 3 and end was 12 the output would be:
3.0
4.0
5.0*
6.0
7.0
8.0
9.0
10.0*
11.0
12.0
The chickenSquare method is close to being correct. I think the problem here is that you are not thinking your way through code you have written. In chickenSquare how many times should the the chicken walk forward and turn to make a square? The easiest way to see this is to do it yourself, walk in a square and you will walk forward and turn a set number of times.
Now, when you created the chickenSquare method you added a parameter. That parameter was suppose to determine the length of each side of the square. So now the question becomes, if you want to use sizeSquare to determine the size of each side of the square, where would sizeSquare be placed in the method? Currently it is used to determine how many sides the chicken walks. The chicken could stay where it is (sizeSquare=0) or it could walk one meter, turn and stop or it could move 1 meter and turn thousands of times before stopping. I should note that the chicken will not necessarily complete the last square. In other words the chicken could end up at a different place and facing a different direction then when it started.

I hope this puts you on the right track.
Mark


Mark Henwood
mhenwood@ieee.org

Last edited by chickentree; 11-18-2015 at 03:53 PM.
   
Reply With Quote