الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تصحيح برنامج

بدأه الطالبه بنان في 23 مايو 2011 · 2 رد · 413 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام علسكم ورحمة الله وبركاته

اريد اضافة فكره الي الكود هي(ان البائع يحذف عنصر مطلوب وبعد ذالك يحسب البرنامج التكلفه من جديد )))كيف اطبق هذا الفكره في الكود ؟؟؟

اريد اضافة الفكره في {case 3 }

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 displayLink() 
       // display ourself
      { 
      System.out.print("\t"+ID);
      System.out.print("\t"+ qui);
      System.out.print("\t"+ Items);
      System.out.println("\t"+price); 
      }
      public void dis()
      { 

      	System.out.println("\t voice  " );
        System.out.print("\t"+ Items);
        System.out.println("\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 displayList()
      {
      System.out.print("\t\tthe menue of our canteen \n");
      System.out.println("\tID\tQuin\tItem name\tprice " );
      Link current = first;       // start at beginning of list
      while(current != null)      // until end of list,
         {
         current.displayLink();   // 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





           theList.insertFirst(4,44,"moka",7);
           theList.insertFirst(3,32,"cappuccino",3);
           theList.insertFirst(2,55,"Burger",4);
           theList.insertFirst(1,67,"french fries", 5);          





     theList.displayList();
     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");

     else
     {
     	System.out.println("wrong");
     	System.out.println("pleas tray again");
     }



	}while(!password.equals("hello"));



                  // display list
        // end main()



      while(true)
         { System.out.println("Enter number to:\n");
         System.out.println("1)show the minu for seller
          ");
         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.displayList();
               else
                  System.out.println("List is empty");
               break;

                case 2:                    
              // search //caculate totale

               int t=0;
               int e=0;
               System.out.println("Enter how many items u want ");
               int a=input.nextInt();


               for(int j=1;j<=a;j++)
               {
               System.out.println("Enter"+j+"item");
                int b=input.nextInt();

               Link f = theList.find( b); 
                        // find item
               if( f != null)
               {

               System.out.println("Found link with key " + f.ID);
                 e= f.qui-1;
                 System.out.println("\nQuintity of "+f.Items+"is"+e);
                 t+= f.price;
                 }
               else
               {


               System.out.println("Can't find link");

                } 
                }

               System.out.println("\nprice ="+t);


                  break;

           case 3:
           //delet

          int h=0;

          System.out.println("Enter price to deldt items");
          int key=input.nextInt();
          Link i = theList.delete(key);        // delete item
          if( i != null )
          System.out.println("Deleted link with key " + i.ID+i.qui+i.Items+i.price);
          else
          System.out.println("Can't delete link");


          System.out.println("price after delet"+h);

          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 link with key " +  q.ID+q.qui+q.Items+q.price);
          else
          System.out.println("Can't delete link");

             }
          else
          if(s==0)
          System.out.println("*******************");


              theList.displayList();       

          break;



           case 4:

           System.out.println("\t enter the number of invoice  " );
           int x=input.nextInt();
           for(int j=0;j<x;j++)



           break;

            default:
               System.out.println("Invalid entry");
            }  // end switch
         }  // end while
      }  // end main()
//--------------------------------------------------------------

//-

-----------------------------------------------------------

}

410602433.gif
#2

بليزززز ردو على موضوعي تسليم المشروع قريب مره بليزززز ردووووو

410602433.gif
#3

ستبحثي عن العنصر في Linked List إذا وجدتيه قمتي بحذفه

ثم ستقومي بخصم قيمة العنصر من الفاتورة السابقة

تحياتي

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…