safriansah

antrian bank linklist

Aug 14th, 2018
4,741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.   class linklist{
  3.     public $head,$tail,$id;
  4.     function __construct(){
  5.       $this->head=null;
  6.       $this->tail=null;
  7.       $this->id=0;
  8.     }
  9.     public function enque($a){
  10.       $baru=new node();
  11.       $baru->input($a);
  12.       if($this->head==null) $this->head=$baru;
  13.       else $this->tail->setNext($baru);
  14.       $this->tail=$baru;
  15.       $this->id++;
  16.     }
  17.     public function deque(){
  18.       if($this->head!=null) $this->head=$this->head->getNext();
  19.     }
  20.     public function view(){
  21.       if($this->head==null) echo"<div class='nomor col-3'> Empty </div>";
  22.       else{
  23.         $a=$this->head;
  24.         $b=1;
  25.         $c=11;
  26.         while($a!=null){
  27.           if($b<=$c) echo $a->read()." ";
  28.           $b++;
  29.           $a=$a->getNext();
  30.         }
  31.         if($b-1>$c) echo '<div class="nomor col-3"> <'.($b-$c-1).'> </div>';
  32.       }
  33.     }
  34.   }
  35. ?>
Add Comment
Please, Sign In to add comment