[cs13001] Lab 8 problems

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Mar 9 22:55:36 EDT 2014


> 
> I'm confused. In the header file, you have the check function as an int
> function and the comments say it should return the index of the element of
> the array. So how can the check function return true if it is an int
> function. shouldn't it return i?

yes, yes, yes! Sorry for the confusion.

When match() returns "true" for the particular element of the array of
ships that matches the location, check() returns the index of this
element.

Thanks,
--
Mikhail

> 
> >
> >
> > > I am in your CS 13001 class and I am having a lot of trouble with
> > > the first part of lab 8, specifically the match and check
> > > functions. I am extremely lost when it comes to these two functions
> > > and it would be very helpful if you could explain them in great
> > > detail to me or give me the psuedocode for them. I also am not sure
> > > what to put as their parameters. If you could help me with these two
> > > functions then I know I can write the rest of the code easily, but
> > > for now I am completely stuck. Please get back to me as soon as you
> > > can! Thanks.
> >
> > Here is the code for function match()
> >
> > bool match(ship s, location el){
> >      if(s.loc.x == el.x && s.loc.y == el.y)
> >         return true;
> >      else
> >         return false;
> > }
> >
> > function check() accepts an array of ships as as the first parameter
> > and location as the second. It then iterates over the array and
> > invokes match() for every element of the array. If match() returns
> > "true" at least once, then check() returns "true"; if match() returns
> > "false" for every element of the array, then check() returns false.


More information about the cs13001 mailing list