[cs13001] Lab 8 problems

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Mar 9 20:16:38 EDT 2014



> 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.

Thanks,
--
Mikhail


More information about the cs13001 mailing list