public void refresh(){
        ArrayList<Card> deck = cardDeck.getCards();
        int num=0;
        for(Card d: deck){
            if(d.getColor()==Color.LOCO) num++;
        }
        if(deck.size()<=num+3)return;

        for(int i = 0 ;i<5;i++){
            cardDeck.add(new Card(initialColorsDealt[i]));     
        }

        for(int i = 0; i<5;i++){
            Card c = cardDeck.deal();
            if(c==null){
                initialColorsDealt[i]=null;
                initialCardsDealt[i] = null;
            }
            else
            {
                initialColorsDealt[i]=c.getColor();
                initialCardsDealt[i] = getImage(c);
            }
        }

        int numLocomotivesInDeck = 0;
        for(int j =0;j<5;j++){
            if(initialColorsDealt[j]==
            Color.LOCO) numLocomotivesInDeck++;
        }

        if(numLocomotivesInDeck>=3){
            refresh();
        }

    }