class WaterSource{
private String s;
WaterSource(){
System.out.println("WaterSource()");
s = "constructed";
}
public String toString(){
return s;
}
}
public class SprinklerSystem {
private String name = "Alex";
private String sex;
private WaterSource wSource;
private double d;
public SprinklerSystem(){
System.out.println("In Sprinkler");
d = 1.0;
wSource = new WaterSource();
}
public String toString(){
if (sex == null) { sex = "male"; }
return
"string" + "=" + name + " " +
"sex" + "=" + sex + " " +
"double" + "=" + d + " " +
"WaterSource" + "=" + wSource;
}
public static void main(String[] args){
SprinklerSystem sprinklers = new SprinklerSystem();
System.out.println(sprinklers);
}
}