In general the endomorphisms of a non-abelian group do not form a ring under the operations of addition and composition of functions. Several papers have dealt with the ring of functions defined on a group which are endomorphisms when restricted to the elements of a cover of the group by abelian subgroups. We give an algorithm which allows us to determine the elements of the ring of functions of a finite $p$-group which arises in this manner when the elements of the cover are required to be either cyclic or elementary abelian of rank $2$. This enables us to determine the actual structure of such a ring as a subdirect product. A key part of the argument is the construction of a graph whose vertices are the subgroups of order $p$ and whose edges are determined by the covering.