Building a Simple Food Ordering System in Java (No Database)
This tutorial walks through creating a complete, database‑free food ordering system in Java, covering class design for dishes, users, orders, and administrators, implementing CRUD operations with in‑memory maps, and providing a console menu for both admin and customer interactions.
The article presents a step‑by‑step guide for implementing a simple food delivery ordering system in Java without using a database. It starts with an overview of the required entity classes—Admin, Dishes, Order, and User—each with appropriate fields and getters/setters.
package com.softeem.lesson23.test2;
public class Admin {
private String aID;
private String account;
private String apwd;
// constructors, getters, setters, toString ...
}
Similarly, the Dishes, Order, and User classes are defined with fields such as dish ID, name, type, price, sales, stock, order ID, timestamps, customer information, etc., and include full constructors, getters, setters, and toString methods.
public class Dishes {
private String dID;
private String dname;
private String dtype;
private LocalDate dtime;
private double price;
private int dsales;
private int dstocks;
// constructors, getters, setters, toString ...
}
The system uses separate management (DAO) classes for each entity, storing objects in static Map collections for quick lookup.
public class AdminSys implements DAO {
static Map map = new HashMap<>();
UserSys u = new UserSys();
OrderSys o = new OrderSys();
DishesSys d = new DishesSys();
// methods for adding dishes, showing dishes with pagination, selecting by type, updating price, deleting, managing users, orders, etc.
}
The OrderSys class implements DAO<Order> and provides methods to insert orders, find by ID, list all orders, and retrieve orders for a specific user.
public class OrderSys implements DAO {
static Map ordermap = new HashMap<>();
static List orderlist = new ArrayList<>();
// insert, findById, findByuId, findAll, delete (TODO)
}
The UserSys class implements DAO<User> and manages user data, including adding users, listing all users, deleting a user, changing passwords, and finding by ID.
public class UserSys implements DAO {
static Map usermap = new HashMap<>();
// insert, findAll, delete, changepwd, findById
}
The DishesSys class implements DAO<Dishes> and provides CRUD operations for dishes, as well as methods to query by type.
public class DishesSys implements DAO {
static Map dishesmap = new HashMap<>();
// insert, findById, findByType, findAll, selectBytype, delete
}
A Menu class ties everything together, offering separate console menus for administrators and regular users. It handles login, displays options, and routes user input to the appropriate service methods.
public class Menu {
static AdminSys admin = new AdminSys();
// showMenu(), userMenu(User user), adminMenu()
}
The Test class contains the main method that launches the application.
public class Test {
public static void main(String[] args) {
Menu m = new Menu();
m.showMenu();
}
}
Throughout the tutorial, the author includes console prompts, input validation, and example data initialization (e.g., default admin account "qwl" with password "123456" and several sample dishes and users). Screenshots of the running program are provided to illustrate the user interface for both admin and customer workflows.
The complete source code is presented in the article, allowing readers to copy, compile, and run the program to see a functional ordering system without any external database dependencies.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.