<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class House {
  
  public static void main(String[] args) {
    
    Room[] rooms= new Room[5];
  
    for (int i=0; i&lt;rooms.length; i++) {
      if (Math.random()&lt; 2.0/3) //{twice as likely to be Room than Bathroom}
        rooms[i]= new Room(10);
      else
        rooms[i]= new Bathroom(20,true);
    }
  
    System.out.println("Clean up or major clean up");  
    for (int i=0; i&lt;rooms.length; i++) {
      if (rooms[i] instanceof Bathroom)
        ((Bathroom) rooms[i]).majorCleanUp();
      else if (rooms[i] instanceof Room)
        rooms[i].clean();
      rooms[i].report();
    }
  }
}</pre></body></html>