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

[مخالف - عنوان غير مناسب :]تصحيح برنامج

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

السلام عليكم

ساعدوني في تصحيح هذا البرنامج بعد تركيب الانترفيس

الكود الاصلي في المرفقات <<<قبل تركيب الانترفيس لفهم فكرة البرنامج

import java.util.Calendar; 
import java.util.Scanner; 

import javax.swing.JFrame; 
import javax.swing.JList; 
import javax.swing.JScrollPane; 

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.ImageIcon;

import java.util.*;
import java.util.Scanner;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*; 
import java.text.*;

 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 String 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 
        return first.ID + "  " + first.qui + "  " + first.Items + "{" 
                + first.price + "}"; 
    } 

    // ------------------------------------------------------------- 
    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() { 


     JFrame frame = new JFrame("WELCOME {ELECTRONIC SYSTEM OF CASHER]");



 String backupD="" ;



   // show a joptionpane dialog using showMessageDialog
    JOptionPane.showMessageDialog(frame,
        "\n\n\t\tThe Menue Of our Canteen \n\n " + backupD + "'.",
        "CASHER SYSTEM",
        JOptionPane.INFORMATION_MESSAGE);



        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() { 

     String backupD1="" ;

     JFrame frame = new JFrame("WELCOME {ELECTRONIC SYSTEM OF CASHER]");

   // show a joptionpane dialog using showMessageDialog
    JOptionPane.showMessageDialog(frame,
        "\n\n\t\tThe Menue Of our Canteen \n\n   \n\t  ID  \tQuin \tItem name  \t\t\t  price "+ backupD1 + "'.",
        "CASHER SYSTEM",
        JOptionPane.INFORMATION_MESSAGE);



        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; 
        int b = 0; 
     int SENTINEL = 54321;
        String str;
        int password = 0;
        int counter = 5;

       while (counter != 0 && password != SENTINEL)
       {


               str = JOptionPane.showInputDialog("Enter Password");

            password = Integer.parseInt(str);

        if(password == SENTINEL)
        {
            JOptionPane.showMessageDialog(null, "CORRECT");
        }
        else if(password!=SENTINEL)
        {
             JOptionPane.showMessageDialog(null, "Wrong try again");
        }
        counter = counter-1;

        if (counter == 0)
        {
            JOptionPane.showMessageDialog(null, "Acces Denied!!! \nPlease contact Helpdesk");      
        }
       }

           String backupDir="" ;

     JFrame frame = new JFrame("WELCOME {ELECTRONIC SYSTEM OF CASHER]");

   // show a joptionpane dialog using showMessageDialog
    JOptionPane.showMessageDialog(frame,
        "WELCOME {ELECTRONIC SYSTEM OF CASHER] " + backupDir + "'.",
        "CASHER SYSTEM",
        JOptionPane.INFORMATION_MESSAGE);


        String[] bn= {

                         (  "  ID    QUIN ITEM     NAME      PRICE "),

       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(); 

        JList list = new JList (bn); 


        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

        frame.add(new JScrollPane(list)); 

        frame.setSize(500, 500); 
        frame.setVisible(true); 



        Scanner input = new Scanner(System.in); 








while(true){

		char mode=' ';	 //initialize char
		mode = JOptionPane.showInputDialog("Please enter the mode, \nA for SHOW MINU OF SELLER\nB for SELECT ITEMS AND ADDING\nM for DELET ITEMSn\nD for DESPLAY INVOICE").charAt(0);




            switch (mode) { 

            case 'A': // show list 
                if (!theList.isEmpty()) 
                    theList.displayList2(); 
                else 
                 JOptionPane.showMessageDialog(null, 
                              "lIST IS EMPTY");
                break; 

           case 'B':
                // search //caculate totale 





                for (int j = 1; j <= a; j++) {
                	 String firstNumber
                 = JOptionPane.showInputDialog ( "Enter how many items u want" ); 



                }



                    Link f = theList.find(b); 
                    // find item 
                    if (f != null) { 
                    JOptionPane.showMessageDialog(null, 
                              "yes we have " + f.qui  + "  Items from  " + f.Items);


                        e = f.qui - 1; 
                          JOptionPane.showMessageDialog(null, 
                              "\nQuintity of " + f.Items  + " Now is " + e);

                        t += f.price; 
                    } else { 

                    JOptionPane.showMessageDialog(null, 
                              "we did not have  " + f.Items);


                    }

                  JOptionPane.showMessageDialog(null, 
                              "PRICE IS =" + t);



                break; 

          case 'C':
                // delet 
             String firstNumber2
                 = JOptionPane.showInputDialog ( "Enter ID of Items to deldt" ); 

                int key = input.nextInt(); 
                Link i = theList.delete(key); // delete item 
                if (i != null) { 

                   JOptionPane.showMessageDialog(null, 
                              "Deleted the ID of number " + i.ID );

                      JOptionPane.showMessageDialog(null, 
                              "Delet the cuintitiy is = " + i.qui  );

                     JOptionPane.showMessageDialog(null, 
                              "Delet the Name Of Item " + i.Items  );

                               JOptionPane.showMessageDialog(null, 
                               "Delet the Price " + i.price );


                    t -= i.price; 
                     JOptionPane.showMessageDialog(null, 
                               "price after delet" + t );


                } else { 
                JOptionPane.showMessageDialog(null, 
                              " Can't delete"  );




                    t -= i.price; 
                      JOptionPane.showMessageDialog(null, 
                              " price after delet" + t );



                } 
                JOptionPane.showMessageDialog(null, 
                              "Do you want to delet other items:enter 1 to delet no press 0 ");
                int s = input.nextInt(); 
                if (s == 1) { 

                 String firstNumber3
                 = JOptionPane.showInputDialog ( "Enterthe number of item to delet" ); 


                    int g = input.nextInt(); 
                    Link q = theList.delete(g); // delete item 
                    if (q != null) { 

                      JOptionPane.showMessageDialog(null, 
                              " Deleted the ID of number " + q.ID   );


                        JOptionPane.showMessageDialog(null, 
                              " Delet the cuintitiy is = " + q.qui   );


                                  JOptionPane.showMessageDialog(null, 
                              " Delet the Name Of Item " + q.Items  );


                                  JOptionPane.showMessageDialog(null, 
                              " Delet the Price " + q.price  );


                        t -= q.price; 
                          JOptionPane.showMessageDialog(null, 
                              " price after delet =" + t  );


                    } else {   JOptionPane.showMessageDialog(null, 
                              " Can't delete"  );




                    } 
                } else if (s == 0) { 

                    System.out.println("*******************"); 
                } 

                break; 

            case 'D': {


                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. 
                JOptionPane.showMessageDialog(null, 
                              " Date: "  );
                JOptionPane.showMessageDialog(null, 
                              months[calendar.get(Calendar.MONTH)]  );

                 JOptionPane.showMessageDialog(null, 
                              " " + calendar.get(Calendar.DATE) + " " );

                  JOptionPane.showMessageDialog(null, 
                            calendar.get(Calendar.YEAR) );

                  JOptionPane.showMessageDialog(null, 
                        "Time: " );


                   JOptionPane.showMessageDialog(null, 
                       calendar.get(Calendar.HOUR) + ":");

                  JOptionPane.showMessageDialog(null, 
                       calendar.get(Calendar.MINUTE) + ":");

                    JOptionPane.showMessageDialog(null, 
                       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); 

                     JOptionPane.showMessageDialog(null, 
                       "Updated time: ");

                    JOptionPane.showMessageDialog(null, 
                       calendar.get(Calendar.HOUR) + ":");

                    JOptionPane.showMessageDialog(null, 
                     calendar.get(Calendar.MINUTE) + ":");

                     JOptionPane.showMessageDialog(null, 
                      calendar.get(Calendar.SECOND));




 Link d = theList.find(b); 


                  JOptionPane.showMessageDialog(null, 
                              " YOU BUYING " + a + " ITEMS IS "   + d.Items );



                  JOptionPane.showMessageDialog(null, 
                              "TOTALE OF PRICE IS =" + t  );





            }
                break; 
            default: 
            }

		  JOptionPane.showMessageDialog(null, 
                              " THANK YOU  "  );


            } // end switch 
        } // end while 

    }

Project Cs204.java

تم تعديل هذه المشاركة بواسطة الطالبه بنان في 9 ديسمبر 2011 في 14:45

410602433.gif
#2

الأخ الكريم/الأخت الكريمة

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

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات. فقرة اختيار عنوان مناسب لمحتوى الموضوع.

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

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

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

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

728x90.png

هذا الموضوع مغلق.

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