#ppp = 10
instability(X) = #providers/10 = 4/10 = 2/5 = .4
responsibility(X) = #clients/10 = 4/10 = 2/5 = .4
stability(X) = 1 – instability(X) = 3/5 = .6
deviance(X) = |3/5 – 2/5| = 1/5 = .2
All of the added code is marked in Company.java (contains all of the class declarations.)
class EmployeeVisitor {
public void visit(Employee e) { }
public void visit(Programmer e) { }
public void visit(Manager e) { }
public void visit(Secretary e) { }
}
class CountProgrammerVisitor extends EmployeeVisitor {
private int numProgrammers = 0;
public void visit(Programmer e) {
numProgrammers++;
}
public int getNumProgrammers() {
return numProgrammers;
}
}
Added to bottom of Company.main:
CountProgrammerVisitor v = new CountProgrammerVisitor();
acme.visit(v);
System.out.println("# programmers = " + v.getNumProgrammers()); //
prints 33
The auctioneer publishes (announces) a new price to the subscribing (registered) bidders. Bidders use a strategy to determine if they will accept the new price. The UML model can be found in auction.uml. Here's a snapshot:
