20-CS-694 Advanced Programming Techniques Spring 2012
Hints for Homework Assignment 2

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

Exceptions for Control - Declarative Style

Due: April 17, 2012 (submit instructions: here)

Add constraints that were not explicitly given
    Make some inferences. For example, the problem states that the Norwegian lives in the first house and the Norwegian lives next to the blue house and the green house is to the left of the white house. So we can conclude that nobody is to the left of the Norwegian, the white house cannot be the first house, the Norwegian is not in the white house, the blue house is the second house, the Norwegian is not in the blue house. These may be added as constraints:
   assert_(!LeftOf("Swede","Norwegian"));
   assert_(!LeftOf("Brit","Norwegian"));
   assert_(!LeftOf("Dane","Norwegian"));
   assert_(!LeftOf("German","Norwegian"));
   assert_(!owner("Norwegian","WhiteHouse"));
   assert_(!owner("Norwegian"."BlueHouse"));
   assert_(positionOf("BlueHouse",2));
   assert_(!positionOf("WhiteHouse",1));
where the quoted strings should be replaced by the appropriate variable values. (I did not do any of this but it would probably speed things up).

More Help