src/main/java/seedu/planner/model/ModelManager.java
private void updateMapping(Contact oldContact, Contact newContact) {
        if (contactActivityMap.containsKey(oldContact)) {
            Activity oldAct = contactActivityMap.remove(oldContact);
            Activity newAct = new Activity(oldAct.getName(), oldAct.getAddress(), newContact,
                    oldAct.getCost().orElse(null), oldAct.getTags(), oldAct.getDuration(),
                    oldAct.getPriority());
            activities.setActivity(oldAct, newAct);
            contactActivityMap.put(newContact, newAct);
        }
        if (contactAccommodationMap.containsKey(oldContact)) {
            Accommodation oldAcc = contactAccommodationMap.remove(oldContact);
            Accommodation newAcc = new Accommodation(oldAcc.getName(), oldAcc.getAddress(), newContact,
                    oldAcc.getTags());
            accommodations.setAccommodation(oldAcc, newAcc);
            contactAccommodationMap.put(newContact, newAcc);
        }
    }
/**
     * Updates the mapping when there is a change to a {@code Contact}. When the {@code Contact} changes, the
     * {@code Activity} and {@code Accommodation} sharing the same contact is also updated.
     */
Updates the mapping when there is a change to a  Contact. When the  Contact changes, the
Activity and  Accommodation sharing the same contact is also updated.
Updates the mapping when there is a change to a Contact . When the Contact changes the Activity and Accommodation sharing the same contact is also updated .
private void updateMapping(Contact oldContact, Contact newContact) {
        if (contactActivityMap.containsKey(oldContact)) {
            Activity oldAct = contactActivityMap.remove(oldContact);
            Activity newAct = new Activity(oldAct.getName(), oldAct.getAddress(), newContact,
                    oldAct.getCost().orElse(null), oldAct.getTags(), oldAct.getDuration(),
                    oldAct.getPriority());
            activities.setActivity(oldAct, newAct);
            contactActivityMap.put(newContact, newAct);
        }
        if (contactAccommodationMap.containsKey(oldContact)) {
            Accommodation oldAcc = contactAccommodationMap.remove(oldContact);
            Accommodation newAcc = new Accommodation(oldAcc.getName(), oldAcc.getAddress(), newContact,
                    oldAcc.getTags());
            accommodations.setAccommodation(oldAcc, newAcc);
            contactAccommodationMap.put(newContact, newAcc);
        }
    }
private void updateMapping ( Contact oldContact , Contact newContact ) { if ( contactActivityMap . containsKey ( oldContact ) ) { Activity oldAct = contactActivityMap . remove ( oldContact ) ; Activity newAct = new Activity ( oldAct . getName ( ) , oldAct . getAddress ( ) , newContact , oldAct . getCost ( ) . orElse ( null ) , oldAct . getTags ( ) , oldAct . getDuration ( ) , oldAct . getPriority ( ) ) ; activities . setActivity ( oldAct , newAct ) ; contactActivityMap . put ( newContact , newAct ) ; } if ( contactAccommodationMap . containsKey ( oldContact ) ) { Accommodation oldAcc = contactAccommodationMap . remove ( oldContact ) ; Accommodation newAcc = new Accommodation ( oldAcc . getName ( ) , oldAcc . getAddress ( ) , newContact , oldAcc . getTags ( ) ) ; accommodations . setAccommodation ( oldAcc , newAcc ) ; contactAccommodationMap . put ( newContact , newAcc ) ; } }
Updates the mapping when there is a change to a {@code Contact}.
Updates the mapping when there is a change to a { @code Contact } .