For a continuous function, the condition is:
\(\lim_{x\to\ a^{-}}f(x) = \lim_{x\to\ a^{+}}f(x) = f(a) \)
so look for the critical points (the points where the definition of the function has been changed) which are 2 and 5.
\(\lim_{x\to\ 2^{-}}f(x) = \lim_{x\to\ 2} (x+2) = 4\)
\(\lim_{x\to\ 2^{+}}f(x) = \lim_{x\to\ 2} (ax+b) = 4 = 2a + b\)
\(\lim_{x\to\ 5^{+}}f(x) = \lim_{x\to\ 5} (3x-2) = 13\)
\(\lim_{x\to\ 5^{-}}f(x) = \lim_{x\to\ 5} (ax + b) = 13 = 5a + b\)
Now we have 2 equations,
\(2a + b = 4 ; 5a + b = 13; \)
Solving them, we get that a = 3 and b = -2