Translation of Janaka's rules into Java