The English genitive doesn't exist in Italian, so it's usually translated using of.
"Classmate" is compagno di classe (mate of class). To avoid repeting classe, it's often shortened to compagno: i compagni della mia classe (the mates of my class).
Chocolate cake is indeed torta di cioccolato, and chicken rice riso di pollo (although riso con pollo [rice with chicken] is much more common).
Genitive is not always translated with di, however, as the preposition ultimately depends on what kind of association there is.
Playing card = carta da gioco
Evening dress = abito da sera
Fruit tree = albero da frutto
Bathing suit = costume da bagno
Generally speaking, di is used to mean "made of", "belonging to", while da conveys a message of "utility": a suit that can be used for bathing, a tree that yeals fruits, a card that can be played and so on.
With food, al is also possible, with the meaning of "dish containing a special ingredient":
Nettle pasta = pasta alle ortiche
Chocolate cake = torta di/al cioccolato
Chicken rice = riso di/con/al pollo
Hope this helps!