well if element X is in group 2 it is a solid metal and if element Z is in group 17 its a non metal.
ionic bonds happen between a metal and a non metal and the metal looses electrons and gives it to the non metal for both to have a full valence energy level or shell.
covelent bonds are bonds that happen between 2 or more non metals and instead of giving valance electrons they share them between each other.