package clist.visitor; import clist.*; /** * Prints the host CLList in the clockwise direction via System.out. */ public class PrintClockwise implements ICLVisitor { public final static PrintClockwise Singleton = new PrintClockwise (); private PrintClockwise() { } /** * Prints a new line. * @param host * @param stop * @param inp * @return */ public Object forEmpty ( CLList host, CLList stop, Object inp) { System.out.println(); return null; } /** * Needs to distinguish the case when the host has one element from the case when * the host has more than one element. * @param host * @param stop * @param inp * @return */ public Object forNonEmpty (CLList host, CLList stop, Object inp) { CLList tail = host.getClockwiseTail(); if (tail.equals (stop)) { System.out.println (host.getClockwiseDat ()); } else { System.out.print (host.getClockwiseDat () + " "); tail.execClockwise (this, stop, null); } return null; } }