Java is fun...kah..???

1:27:00 AM

salam..


import java.text.*;
public class BSTAirline
{
AirlineTreeNode root;
public BSTAirline()
{ root = null; }//BSTAirline
public void insert(Airline a)
{
if(root == null)
root = new AirlineTreeNode(a);
else
insert(a,root);
}//insert
public void insert(Airline data,AirlineTreeNode node)
{
if(node == null)
node = new AirlineTreeNode(data);
else
{
if(data.getNum()
{
if(node.left == null)
node.left = new AirlineTreeNode(data);
else
insert(data,node.left);
}//if
else
{
if(node.right == null)
node.right = new AirlineTreeNode(data);
else
insert(data,node.right);
}//else
}//else
}//insert
public void findInfo(String dest)
{
findInfo(dest, root);
}//displayAirline
public void findInfo(String dest, AirlineTreeNode a)
{
if(a != null)
{
if(a.data.getDestination().equalsIgnoreCase(dest))
{
System.out.println("AIRLINE INFO");
a.data.display();
}//if
findInfo(dest, a.left);
findInfo(dest, a.right);
}//if
}//displayAirline
public void displayAll() // Display passengers in ascending order
{ displayAll(root); }//displayAll
public void displayAll(AirlineTreeNode node)
{
if(node == null)
return;
displayAll(node.left);
node.data.display();
System.out.println("+++++++++++++++++++++++++++++++++++++");
displayAll(node.right);
}//displayAll
public void newPrice()
{ newPrice(root); }//newPrice
public void newPrice(AirlineTreeNode node)
{
if(node == null)
return;
newPrice(node.left);
node.data.display();
double temp = node.data.getPrice()-(node.data.getPrice()*0.15);
DecimalFormat df = new DecimalFormat("#.##");
System.out.println("New Price:RM "+(df.format(temp)));
System.out.println();
newPrice(node.right);
}//calculate and display new price
public int totalPassenger()
{ return totalPassenger(root); }//totalPassenger
public int totalPassenger(AirlineTreeNode node)
{
if(node == null)
return 0;
int count = node.data.getNum();
return count +totalPassenger(node.left)+totalPassenger(node.right);
}//totalPassenger
}//class BSTAirline

pesanan penaja : xde idea..MySpace

You Might Also Like

15 kutukan membina...

  1. yela tu java best. hahahah

    arief, akak sheh udah link kamo. hahahha (akak yer jgn memaen) ;p

    ReplyDelete
  2. panggil aku shEh >> fun ape..
    haha..tima kaseh sudi link dak nsem nih..haha.

    ReplyDelete
  3. oh shit.. i forgot java edy =/

    ReplyDelete
  4. kenwooi >> haha..nothings matter anyway.

    ReplyDelete
  5. fuhhhh dahsyat!!! boleh penin 1 badan!

    ReplyDelete
  6. Nur Su'aidah >> hoho..ni basic2..tahap rendah ag..aku baru nk belajo..

    ReplyDelete
  7. pasneh leh la ko tlg aku wat asiment java ek

    ReplyDelete
  8. arief...wat saya penink kepala...saya beljar java 1 tahun ...masih dalam kbluraan.....hahahahhaha

    ReplyDelete
  9. dh cm coding html jek.

    allergic tgk
    so lariiiiiiiiiiiiiiiii.

    ReplyDelete
  10. pensel kontot >> bleh saje.upah bape ribu..?

    AyanaAsham >> haha..ape kes sampai mau lari ni kak oi.

    lala >> merepek lam bahase komputer.

    ReplyDelete
  11. java? itu java ke?
    sib baik tak amik IT dulu

    ReplyDelete
  12. Cik Syima >> a'ah..ni lbih kuwang basic die jew.

    ReplyDelete
  13. java xbesh!
    serabot2... byk ulat2..xpaham..hee;)

    ReplyDelete
  14. akiN aMar >> haha..besh ape java..ape da..

    ReplyDelete