mercredi 1 février 2017

how to notify observer with 2 arguments change?

I'm new with design patterns. I'm trying to solve this exercise with java about observer design pattern: we have a point class and a segment class

Point{
void translater(int dx,int dy);
double distance(Point p);
}

Segment{
private double longueur;
public Segment(Point ex1,Point ex2){....longueur=ex1.distance(ex2);}

public double getLongueur(){}

}

If we do p.translater x and y of the point change, I want the segment class to be notified. How can I notify observer with the x and y values? Note, I must not change the getLongueur method.

Aucun commentaire:

Enregistrer un commentaire