Re: 20.1/20.2

0 views
Skip to first unread message

Jay McCarthy

unread,
Dec 2, 2011, 7:04:13 PM12/2/11
to John Steagall, byu-cs-jm-142-Fall-2011
No.

In 1, you change the array so that it has all new Posns in it.

In 2, you change the Posns so that they have new numbers in the them, but the array is the same.

The two functions have the same contracts.

Jay

On Fri, Dec 2, 2011 at 4:56 PM, John Steagall <swimme...@gmail.com> wrote:
Jay-
just to understand a little better.  In 20.1 we take the whole Posn
and translate both numbers in it by the same amount? In 20.2 we take
the separate numbers of the Posn and translate each by a different
amount?  and by translate is it something like * 2 or +2 or something
totally different?
just want to make sure im understanding this right.
Thanks for all your help.
John Steagall



--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Jay McCarthy

unread,
Dec 2, 2011, 8:17:21 PM12/2/11
to John Steagall, byu-cs-jm-142-Fall-2011
Neither function returns an array.

The first one modifies the array that came in to have new Posns in it.

The second one modifies the posns that came into it to have new numbers in them

You can tell the first from the second by looking at the Posns that were in the array originally.

Jay

On Fri, Dec 2, 2011 at 5:38 PM, John Steagall <swimme...@gmail.com> wrote:
I think i figured it out.
1 and 2 - Posn* two = {new Posn(1, 2) , new Posn(3, 4)} and returns
{new Posn(2, 1) , new Posn(4, 3)}
but its all in the way you do it right?
thanks for helping
John Steagall

On Fri, Dec 2, 2011 at 5:16 PM, John Steagall <swimme...@gmail.com> wrote:
> so...
> for 1 Posn* anArray[] = (new Posn(2,3), new Posn(4, 5)) would return
> something like (new Posn(5, 6),  new Posn(7, 8), new Posn(3, 4). which
> starts with one array with 2 things and returns a 3 posns all
> different.or should this one be more like
> (new Posn(2,3), new Posn(4, 5), new Posn(2, 2))
> and for 2 Posn* anArray[] = (new Posn(2,3), new Posn(4, 5)) would
> return something like (new Posn(5, 6),  new Posn(7, 8),)  which takes
> in an array and returns the same 2 part array with different numbers
> it it
> Im not sure i understand right...
> thanks for helping me understand
> John Steagall
Reply all
Reply to author
Forward
0 new messages