We consider an optimal state-age dependent replacement problem for a network system composed of a main system and a sub-system with N components. The component's functioning times are exponentially distributed random variables with the same parameters, and every failed component is repaired by one repairman by taking an exponentially distributed random time. Repaired components are as good as new. The main system is subject to a sequence of randomly occurring shocks and each shock causes a random amount of damage. Shock arrivals and magnitudes depend on the accumulated damage level of the main system itself and the number of the functioning components of the sub-system. Any of the shocks or component's failures might cause the main system to fail. Upon failure of the main system, it is replaced and emergency repairs for all failed components are carried out. Our aim is to determine an optimal state-age dependent replacement policy which minimizes the long-run average cost over the infinite horizon.