import java.util.Calendar;
import java.util.Scanner;
class Link
   {
  public int ID;
   public int qui;
   public String Items;
   public int price;           // data item
   public Link next;              // next link in list
// -------------------------------------------------------------
   public Link(int a,int b,String Ite, int p)           // constructor
      { ID = a; 
      qui=b;                             // constructor
      Items = Ite;
      price = p;
      
       }                           //  set to null)
// -------------------------------------------------------------
  public void displayLink1() 
       // display ourself
      { 
      
      
      System.out.println("\t"+Items+"\t\t{"+price+"}");
      
      System.out.println(""); 
      }
      
      public void displayLink2() 
       // display ourself
      { 
      System.out.print("\t"+ID);
      System.out.print("\t"+ qui);
      
      System.out.print("\t"+Items);
      
      System.out.println("\t\t{"+price+"}"); 
      }
     
      
   } 
////////////////////////////////////////////////////////////////
class LinkList
   {
   private Link first;            // ref to first link on list

// -------------------------------------------------------------
   public LinkList()              // constructor
      {
      first = null;               // no links on list yet
      }
// -------------------------------------------------------------
   public boolean isEmpty()       // true if list is empty
      {
      return (first==null);
      }
// -------------------------------------------------------------
                                  // insert at start of list
   public void insertFirst(int ID,int SD, String Item, int pri)
      {                           // make new link
      Link newLink = new Link(ID,SD, Item, pri);
      newLink.next = first;       // newLink --> old first
      first = newLink;            // first --> newLink
      }
// -------------------------------------------------------------
public Link find(int key)      // find link with given key
      {                           // (assumes non-empty list)
      Link current = first;              // start at 'first'
      while(current.ID != key)        // while no match,
         {
         if(current.next == null)        // if end of list,
            return null;                 // didn't find it
         else                            // not end of list,
            current = current.next;      // go to next link
         }
      return current;                    // found it
      } 
      
      ///////////////////////////////////////
  public Link delete(int key)    // delete link with given key
      {                           // (assumes non-empty list)
      Link current = first;              // search for link
      Link previous = first;
      while(current.ID != key)
         {
         if(current.next == null)
            return null;                 // didn't find it
         else
            {
            previous = current;          // go to next link
            current = current.next;
            }
         }                               // found it
      if(current == first)               // if first link,
         first = first.next;             //    change first
      else                               // otherwise,
         previous.next = current.next;   //    bypass it
      return current;
      }  
// -------------------------------------------------------------

	

   public void displayList1()
      {
      	System.out.println("\t\t*********** Welcome ***********");
      System.out.print("\n\n\t\tThe Menue Of our Canteen \n\n");
      System.out.println("\n\t ææItem name ææ\t\tææ price ææ");
      System.out.println("");
      Link current = first;       // start at beginning of list
      while(current != null)      // until end of list,
         {
         current.displayLink1();   // print data
         current = current.next;
         // move to next link
         }
      System.out.println("");
      }
      
      
      public void displayList2()
      {
      System.out.print("\t\täää The Menue Of our Canteen äää \n\n");
       System.out.println("\n\tID\tQuin\tItem name \t\t\tprice " );
      Link current = first;       // start at beginning of list
      while(current != null)      // until end of list,
         {
         current.displayLink2();   // print data
         current = current.next;
         // move to next link
         }
      System.out.println("");
      }
      
     
      
      
      
// -------------------------------------------------------------
   }  // end class LinkList
////////////////////////////////////////////////////////////////
class LinkListApp
   {
   public static void main(String[] args) 
      {
      LinkList theList = new LinkList();  // make new list
      
       
           
           int t=0;
           int e=0;
           int a=0;
       
           theList.insertFirst(33,20,"bananas milk    ",2);
           theList.insertFirst(32,20,"strawberry milk ",2);
           theList.insertFirst(31,70,"chocolate milk  ",2);
           theList.insertFirst(30,42,"fresh juice     ",4);
           theList.insertFirst(29,22,"lemon juice     ",3);
           theList.insertFirst(28,50,"mirinda  orange ",2);
           theList.insertFirst(27,66,"mirinda apple   ",2);
           theList.insertFirst(26,70,"coca-cola       ",2);
           theList.insertFirst(25,60,"mango juice     ",3);
           theList.insertFirst(24,78,"strawberry juice",1);
           theList.insertFirst(23,50,"tissue          ",1);
           theList.insertFirst(22,20,"cheese cake     ",8);
           theList.insertFirst(21,22,"spinach pie     ",3);
           theList.insertFirst(20,23,"pizza           ",3);
           theList.insertFirst(19,40,"popcorn         ",3);
           theList.insertFirst(18,25,"ice coffee      ",8);
           theList.insertFirst(17,33,"ice juice       ",3);
           theList.insertFirst(16,20,"turkish coffee  ",6);
           theList.insertFirst(15,35,"french coffee   ",7);
           theList.insertFirst(14,30,"coffee          ",3);
           theList.insertFirst(13,43,"tea with milk   ",2);
           theList.insertFirst(12,50,"tea             ",1);
           theList.insertFirst(11,67,"code red        ",3);
           theList.insertFirst(10,70,"bison           ",3);
           theList.insertFirst(9,115,"pepsi           ",2);
           theList.insertFirst(8,87,"orange juice     ",1);
           theList.insertFirst(7,33,"doughnut         ",4);
           theList.insertFirst(6,22,"thyme pie        ",3);
           theList.insertFirst(5,54,"cheese pie       ",2);
           theList.insertFirst(4,44,"moka             ",7);
           theList.insertFirst(3,32,"cappuccino       ",3);
           theList.insertFirst(2,55,"Burger           ",5);
           theList.insertFirst(1,40,"french fries     ",3);
           
                     
       
      
      
                theList.displayList1();
      
     
     Scanner input=new Scanner(System.in);
     
     String password;
     System.out.println( "Please enter your password ");
     do
     {
     
     
      password=input.nextLine();
     if(password.equals("hello"))
     
     System.out.println("correct\n");
     
     else
     {
     	System.out.println("wrong");
     	System.out.println("pleas tray again");
     }
     
     
     
	}while(!password.equals("hello"));
	
     

                  // display list
        // end main()
         
    

      while(true)
         { System.out.println("\nEnter number to:\n");
         System.out.println("1)show the minu for seller\n ");
         System.out.println("2)selecte the name of items and calculating the price\n");
         System.out.println("3)delet items after the order  \n");
         System.out.println("4)display the invoice\n");
         
         int num=input.nextInt();       // get user's option
         switch(num)
            {
            	
            case 1:                    // show list
               if( !theList.isEmpty() )
                  theList.displayList2();
               else
                  System.out.println("List is empty");
               break;
            
                case 2:                    
              // search //caculate totale
            
               
               System.out.println("Enter how many items u want ");
               a=input.nextInt();
               
               
               for(int j=1;j<=a;j++)
               {
               
               System.out.println("\nEnter item ÏÏ "+j+" ÏÏ \n\n");
                int b=input.nextInt();
                
               Link f = theList.find( b); 
                        // find item
               if( f != null)
               {
               
               System.out.println("yes we have "+f.qui+"  Items from  "+f.Items);
                 e= f.qui-1;
                 System.out.println("\nQuintity of "+f.Items+" Now is "+e);
                 t+= f.price;
                 }
               else
               {
               
               
               System.out.println("we did not have  "+f.Items);
                 
                } 
                }
               
               System.out.println("\n ÒÒ price ="+t);
                
                
                  break;
               
           case 3:
           //delet
           
          
          
          System.out.println("Enter ID of Items to deldt ");
          int key=input.nextInt();
          Link i = theList.delete(key);        // delete item
          if( i != null )
          {
          
           System.out.println("Deleted the ID of number "+  i.ID+"\n");
           System.out.println("Delet the cuintitiy is = "+i.qui +"\n");
           System.out.println("Delet the Name Of Item "+ i.Items+"\n" );
           System.out.println("Delet the Price "+i.price+"\n");
           t-=i.price;
          
          System.out.println("price after delet"+t);
          } 
          else
          {
          
          System.out.println("Can't delete ");
          
          t-=i.price;
          
          System.out.println("price after delet"+t);
}
          System.out.println("Do you want to delen other items:enter 1 to delet no press 0 ");  
          int s=input.nextInt();
          if(s==1)
          {
             
          System.out.println("Enterthe number of item to delet");
          int g=input.nextInt();
          Link q = theList.delete(g);        // delete item
          if( q != null )
          {
          
           System.out.println("Deleted the ID of number "+  q.ID+"\n");
           System.out.println("Delet the cuintitiy is = "+q.qui +"\n");
           System.out.println("Delet the Name Of Item "+ q.Items+"\n" );
           System.out.println("Delet the Price "+q.price+"\n");
          t-=q.price;
          System.out.println("price after delet ="+t);
          }
          else
          {
          
          System.out.println("Can't delete ");
           
             }
             }
          else
          if(s==0) 
          {
          
          System.out.println("*******************");
          }
         
                    
          
          break;
          
          
           
           case 4:
           {
           
          System.out.println("\t\n\n***********Sucess canteen ************ \n\n" ); 
       String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
        "Sep", "Oct", "Nov", "Dec" };

    Calendar calendar = Calendar.getInstance();

    // Display current time and date information.
    System.out.print("Date: ");
    System.out.print(months[calendar.get(Calendar.MONTH)]);
    System.out.print(" " + calendar.get(Calendar.DATE) + " ");
    System.out.println(calendar.get(Calendar.YEAR));

    System.out.print("Time: ");
    System.out.print(calendar.get(Calendar.HOUR) + ":");
    System.out.print(calendar.get(Calendar.MINUTE) + ":");
    System.out.println(calendar.get(Calendar.SECOND));

    // Set the time and date information and display it.
    calendar.set(Calendar.HOUR, 10);
    calendar.set(Calendar.MINUTE, 29);
    calendar.set(Calendar.SECOND, 22);

    System.out.print("Updated time: ");
    System.out.print(calendar.get(Calendar.HOUR) + ":");
    System.out.print(calendar.get(Calendar.MINUTE) + ":");
    System.out.println(calendar.get(Calendar.SECOND));
     
     
   
     
     
     
           System.out.println("ÒÒYou buying "+a+"Items ÒÒ \n" );
     
           
           
       System.out.println("\n ÒÒ Total Of The price ="+t);
       
      System.out.print("\t\n\n&&&&&&&&&&&&&&&&&&&&&\n\n");
      System.out.println("\t\nThank you     Come agine!!\n" );   
         }  
           break;
           default:
               System.out.println("Thank You For Comming");
            }  // end switch
         }  // end while
      }  // end main()
//--------------------------------------------------------------
    
//------------------------------------------------------------
 }