package thisandthat;

import math.Maths;
import math.cipher.Encoder;

public class NameToNumber{
	
	protected String text;
	
	public NameToNumber(){
	}
	
	public NameToNumber(String str){
		text = str;
	}
	
	public String digitSumFinalToText(){
		return digitSumFinalToText(text);
	}
	
	public static String digitSumFinalToText(String text){
		int sum = Encoder.strToNumber(text);
		StringBuffer sb = new StringBuffer();
		sb.append(sum);
		while(sum > 9){
			sum = Maths.digitSum(sum);
			sb.append("\n"+sum);
		}
		return sb.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String str = args.length!=0 ? args[0].toString() : "Daniel";
		NameToNumber ntn =  new NameToNumber(str);
		System.out.println(str);
		String sb = ntn.digitSumFinalToText();
		System.out.println(sb);
	}

}
