

{"id":145790,"date":"2025-07-11T12:04:41","date_gmt":"2025-07-11T06:34:41","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=145790"},"modified":"2025-07-11T12:15:21","modified_gmt":"2025-07-11T06:45:21","slug":"restaurant-order-processing-system-in-dsa-python","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/","title":{"rendered":"DSA Python Project &#8211; Restaurant Order Processing System"},"content":{"rendered":"<h3>Program 1<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#  Project: Restaurant Order Processing System(Based on Doubly linked list and DQUEUE)\r\n   \r\n#  Features:\r\n# 1. Add order at the end of the queue (new order)\r\n# 2. Serve the first order (remove from front)\r\n# 3. Cancel the last order (remove from end)\r\n# 4. View all pending orders (from first to last)\r\n# 5. Search order according to order ID\r\n# 6. Search order according to customer name\r\n# 7. Total Count of pending orders\r\n\r\n\r\nclass Order:     # Node \r\n    def __init__(self, order_id, customer_name, food_item):\r\n        self.prev = None\r\n        self.order_id = order_id\r\n        self.customer_name = customer_name\r\n        self.food_item = food_item\r\n        self.next = None\r\n\r\nclass RestaurantOrderSystem:\r\n    def __init__(self):\r\n        self.head = None\r\n        self.tail = None\r\n        self.next_order_id = 1\r\n\r\n    def add_order(self, customer_name, food_item):\r\n        new_order = Order(self.next_order_id, customer_name, food_item)\r\n        self.next_order_id += 1\r\n\r\n        if self.head is None:\r\n            self.head = self.tail = new_order\r\n        else:\r\n            self.tail.next = new_order\r\n            new_order.prev = self.tail\r\n            self.tail = new_order\r\n\r\n        print(f\" Order #{new_order.order_id} added for {customer_name}: {food_item}\")\r\n\r\n    def serve_order(self):\r\n        if self.head is None:\r\n            print(\"No orders to serve.\")\r\n            return\r\n\r\n        print(f\" Serving Order #{self.head.order_id}: {self.head.customer_name} - {self.head.food_item}\")\r\n        temp=self.head\r\n        self.head = self.head.next\r\n        if self.head!=None:\r\n            self.head.prev = None\r\n        else:\r\n            self.tail = None\r\n        del temp\r\n\r\n    def cancel_last_order(self):\r\n        if self.tail is None:\r\n            print(\"No orders to cancel.\")\r\n            return\r\n\r\n        print(f Cancelling Order #{self.tail.order_id}: {self.tail.customer_name} - {self.tail.food_item}\")\r\n        temp=self.tail\r\n        self.tail = self.tail.prev\r\n        if self.tail!=None:\r\n            self.tail.next = None\r\n        else:\r\n            self.head = None\r\n        del temp\r\n    def view_orders(self):\r\n        if self.head is None:\r\n            print(\"No pending orders.\")\r\n            return\r\n\r\n        print(\"\\n--- Pending Orders ---\")\r\n        temp = self.head\r\n        while temp!=None:\r\n            print(f\"Order #{temp.order_id:3d} | Customer: {temp.customer_name:15} | Item: {temp.food_item}\")\r\n            temp = temp.next\r\n\r\n    def search_by_id(self, order_id):\r\n        temp = self.head\r\n        while temp!=None:\r\n            if temp.order_id == order_id:\r\n                print(f\" Found Order #{temp.order_id}: {temp.customer_name} - {temp.food_item}\")\r\n                return\r\n            temp = temp.next\r\n        print(\" Order ID not found.\")\r\n\r\n    def search_by_name(self, name):\r\n        temp = self.head\r\n        found = False\r\n        while temp:\r\n            if temp.customer_name.lower() == name.lower():\r\n                print(f\" Order #{temp.order_id}: {temp.food_item}\")\r\n                found = True\r\n            temp = temp.next\r\n        if not found:\r\n            print(f\" No orders found for {name}\")\r\n\r\n    def count_orders(self):\r\n        count = 0\r\n        temp = self.head\r\n        while temp:\r\n            count += 1\r\n            temp = temp.next\r\n        print(f\" Total pending orders: {count}\")\r\n\r\n    def menu(self):\r\n        while True:\r\n            print(\"\\n========== Restaurant Order System ==========\")\r\n            print(\"1. Add New Order\")\r\n            print(\"2. Serve First Order\")\r\n            print(\"3. Cancel Last Order\")\r\n            print(\"4. View All Orders\")\r\n            print(\"5. Search Order by ID\")\r\n            print(\"6. Search Order by Customer Name\")\r\n            print(\"7. Count Pending Orders\")\r\n            print(\"8. Exit\")\r\n            print(\"\\n=======================================\\n\")\r\n            choice = input(\"Choose an option: \")\r\n\r\n            if choice == '1':\r\n                name = input(\"Enter customer name: \")\r\n                item = input(\"Enter food item: \")\r\n                self.add_order(name, item)\r\n            elif choice == '2':\r\n                self.serve_order()\r\n            elif choice == '3':\r\n                self.cancel_last_order()\r\n            elif choice == '4':\r\n                self.view_orders()\r\n            elif choice == '5':\r\n                try:\r\n                    order_id = int(input(\"Enter Order ID: \"))\r\n                    self.search_by_id(order_id)\r\n                except ValueError:\r\n                    print(\"Invalid input.\")\r\n            elif choice == '6':\r\n                name = input(\"Enter customer name: \")\r\n                self.search_by_name(name)\r\n            elif choice == '7':\r\n                self.count_orders()\r\n            elif choice == '8':\r\n                print(\"Exiting system. Goodbye!\")\r\n                break\r\n            else:\r\n                print(\"Invalid option. Try again.\")\r\n\r\n# Run the application\r\nif __name__ == \"__main__\":\r\n    system = RestaurantOrderSystem()\r\n    system.menu()<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Program 1 # Project: Restaurant Order Processing System(Based on Doubly linked list and DQUEUE) # Features: # 1. Add order at the end of the queue (new order) # 2. Serve the first order&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32847],"tags":[32853,32922,32848,32849,34838,34807,34862,34859,34863,34864],"class_list":["post-145790","post","type-post","status-publish","format-standard","hentry","category-dsa-python-tutorials","tag-dsa-python","tag-dsa-python-practical","tag-dsa-using-python","tag-dsa-using-python-program","tag-dsa-using-python-project","tag-restaurant-order-processing-system","tag-restaurant-order-processing-system-in-dsa-python","tag-restaurant-order-processing-system-project","tag-restaurant-order-processing-system-project-in-dsa-python","tag-restaurant-order-processing-system-using-dsa-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>DSA Python Project - Restaurant Order Processing System - DataFlair<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DSA Python Project - Restaurant Order Processing System - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Program 1 # Project: Restaurant Order Processing System(Based on Doubly linked list and DQUEUE) # Features: # 1. Add order at the end of the queue (new order) # 2. Serve the first order&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-11T06:34:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-11T06:45:21+00:00\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DSA Python Project - Restaurant Order Processing System - DataFlair","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/","og_locale":"en_US","og_type":"article","og_title":"DSA Python Project - Restaurant Order Processing System - DataFlair","og_description":"Program 1 # Project: Restaurant Order Processing System(Based on Doubly linked list and DQUEUE) # Features: # 1. Add order at the end of the queue (new order) # 2. Serve the first order&#46;&#46;&#46;","og_url":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2025-07-11T06:34:41+00:00","article_modified_time":"2025-07-11T06:45:21+00:00","author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"DSA Python Project &#8211; Restaurant Order Processing System","datePublished":"2025-07-11T06:34:41+00:00","dateModified":"2025-07-11T06:45:21+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/"},"wordCount":11,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"keywords":["dsa python","dsa python practical","dsa using python","dsa using python program","dsa using python project","restaurant order processing system","restaurant order processing system in dsa python","restaurant order processing system project","restaurant order processing system project in dsa python","restaurant order processing system using dsa python"],"articleSection":["DSA using Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/","url":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/","name":"DSA Python Project - Restaurant Order Processing System - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"datePublished":"2025-07-11T06:34:41+00:00","dateModified":"2025-07-11T06:45:21+00:00","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/restaurant-order-processing-system-in-dsa-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"DSA using Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/dsa-python-tutorials\/"},{"@type":"ListItem","position":3,"name":"DSA Python Project &#8211; Restaurant Order Processing System"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=145790"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145790\/revisions"}],"predecessor-version":[{"id":145804,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145790\/revisions\/145804"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=145790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=145790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=145790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}