For this case, the first thing we must do is define variables.
We have then:
y: number of caps
x: number of shirts
We now write the system of equations that represents the problem:

The graphical solution of the system of equations (see attached image) is:

Therefore, we have 4 shirts and 4 caps.
Answer:

See attached image for the graphic
number of caps = 4
number of shirts = 4