package project_3;

import java.io.PrintWriter;

public class PrintOnFile {
	/*This Class print the information in file*/
	
	private HashTable table;

	PrintWriter w;

	public PrintOnFile(HashTable table) {
		this.table = table;
	}

	public void print(){

		try {
			String s="";

			w = new PrintWriter("Result.txt");

			for (int i = 0; i < table.getSize(); i++) {
				
				if(table.getData(i) != null)
					s+=i+": Name: "+((City)(((HashNode)table.getData(i)).getData())).getName()+", No Of Tourist : "+
							((City)(((HashNode)table.getData(i)).getData())).getTouristNo()+"\r\n ********************* \r\n";
				else
					s+=i+":  ---- \r\n"+"********************* \r\n";
			}
			
			w.println(s);
			w.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
