Hi, as I understand it, the adjective has to match the gender of the noun it describes. In this sentence, "sok" is a masculine noun, and therefore the adjective has to end with "y", "smaczny". When an adjective describes a feminine or neutral noun, it has to end with "a" and "e" respectively. For example, "kobieta" is a feminine noun, and therefore if you want to say "A good woman", you say "Dobra kobieta", not dobry or dobre. So to sum up, to inflect an adjective you first need to identify the noun it is describing and figure out its gender. I really hope this helped you. Good luck!
Just to add to this, adjectives also depend on case and number.
To give an idea of some of the adjective endings (in singular), for genders masc. animate, masc. inanim., neuter, feminine respectively...
Nominative, as mentioned: -y / -y / -e / -a
Accusative: -ego / -y / -e / -ą
Genitive: -ego / -ego / -ego / -ej