Locating-chromatic number for a graph of two components