2Q's help displaying site map on linked list and help with looping

[b]Hi, im needing a bit of help with two parts of my program, firstly its finding a more efficient way of displaying my site map using recursive methods or loops, here is the simple method of how i displayed it to get just something working:[/b]
[italic]
public void displaySiteMap()
{
System.out.println (" " +homePage.page.getName());//home

System.out.println (" "+homePage.down.page.getName());//shops

System.out.println (" "+homePage.down.down.page.getName());//paisely

System.out.println (" "+homePage.down.down.across.page.getName());//hamilton

System.out.println (" "+homePage.down.across.page.getName());//news

System.out.println (" "+homePage.down.across.across.page.getName());//products

System.out.println (" "+homePage.down.across.across.down.page.getName());//kitchen


System.out.println (" "+homePage.down.across.across.down.down.page.getName());//kettles


System.out.println (" "+homePage.down.across.across.down.down.across.page.getName());//cookers

System.out.println (" "+homePage.down.across.across.down.down.across.across.page.getName());//toaster

System.out.println (" "+homePage.down.across.across.down.down.across.page.getName());//bathroom

}[/italic]

[b]Secondly, i cant understand why this keeps loop the output:[/b]

[italic]public Site(){

this.homePage=new PageNode();
this.homePage.page=new Page("Home");//HomePage is created
this.currentPage=this.homePage;//set homepage to current page

do{
AddLink=Input.getString(" Do you wish to add a new Page (y/n): ");
if (AddLink =="y" ){
PageName=Input.getString(" Enter the name of the page: ");
addPage(PageName,this.currentPage);}
else{
System.out.println(" Invalid Answer, try again, ");
AddLink=Input.getString(" Do you wish to add a new Page (y/n): ");}
}while(AddLink!="N" || AddLink!="n");
}[/italic]
[b]thanks very much for any help you can provide :)[/b]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories