Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Date;
- import java.util.List;
- import java.util.ArrayList;
- // Base class for all products
- class Product {
- protected int id;
- protected String name;
- protected String description;
- protected float price;
- protected float amount;
- protected Date expiryDate;
- public Product(int id, String name, String description, float price, float amount, Date expiryDate) {
- this.id = id;
- this.name = name;
- this.description = description;
- this.price = price;
- this.amount = amount;
- this.expiryDate = expiryDate;
- }
- public void setPrice(float newPrice) {
- this.price = newPrice;
- }
- public void setDescription(String newDescription) {
- this.description = newDescription;
- }
- }
- class MeatProduct extends Product {
- public MeatProduct(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class DairyItem extends Product {
- public DairyItem(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class FreshProduct extends Product {
- public FreshProduct(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class ChilledItem extends Product {
- public ChilledItem(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class SmokingItem extends Product {
- public SmokingItem(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class BeverageItem extends Product {
- public BeverageItem(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class AlcoholicBeverage extends Product {
- public AlcoholicBeverage(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class BreadProduct extends Product {
- public BreadProduct(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class DessertItem extends Product {
- public DessertItem(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- class PersonalCareProduct extends Product {
- public PersonalCareProduct(int id, String name, String description, float price, Date expiryDate) {
- super(id, name, description, price, 0, expiryDate);
- }
- }
- // Order class
- class Order {
- private int id;
- private User user;
- private List<Product> products;
- private float totalPrice;
- private String status;
- private Courier courier;
- public Order(int id, User user) {
- this.id = id;
- this.user = user;
- this.products = new ArrayList<>();
- this.status = "New";
- }
- public void addProduct(Product product) {
- products.add(product);
- totalPrice += product.price;
- }
- public float getTotalPrice() {
- return totalPrice;
- }
- public void setStatus(String status) {
- this.status = status;
- }
- }
- // User management
- class User {
- private int id;
- private String fullName;
- private String address;
- private List<Card> cards;
- private String username;
- private String password;
- public User(int id, String fullName, String address, String username, String password) {
- this.id = id;
- this.fullName = fullName;
- this.address = address;
- this.username = username;
- this.password = password;
- this.cards = new ArrayList<>();
- }
- public void addCard(Card card) {
- cards.add(card);
- }
- public void changePassword(String newPassword) {
- this.password = newPassword;
- }
- }
- // Payment system
- abstract class Payment {
- public abstract void confirmPayment();
- }
- class CardPayment extends Payment {
- private String cardNumber;
- public CardPayment(String cardNumber) {
- this.cardNumber = cardNumber;
- }
- public boolean verifyBankCard() {
- // Placeholder for card verification logic
- return true;
- }
- @Override
- public void confirmPayment() {
- if (verifyBankCard()) {
- System.out.println("Payment confirmed via card.");
- }
- }
- }
- class CashPayment extends Payment {
- private float cashAmount;
- public CashPayment(float cashAmount) {
- this.cashAmount = cashAmount;
- }
- @Override
- public void confirmPayment() {
- System.out.println("Payment confirmed with cash.");
- }
- }
- // Admin class
- class Admin {
- private int id;
- private String fullName;
- public Admin(int id, String fullName) {
- this.id = id;
- this.fullName = fullName;
- }
- public void addProduct(Product product) {
- // Add product logic
- }
- public void deleteProduct(Product product) {
- // Delete product logic
- }
- public void editProduct(Product product) {
- // Edit product logic
- }
- public void createCoupon(Coupon coupon) {
- // Create coupon logic
- }
- }
- // Address and coupon management
- class Address {
- private String name;
- private String address;
- public Address(String name, String address) {
- this.name = name;
- this.address = address;
- }
- }
- class Coupon {
- private String code;
- private float discountPercentage;
- private Date expiryDate;
- public Coupon(String code, float discountPercentage, Date expiryDate) {
- this.code = code;
- this.discountPercentage = discountPercentage;
- this.expiryDate = expiryDate;
- }
- }
- // Reporting system
- class Report {
- private Date day;
- private List<Order> orders;
- private float revenue;
- public Report(Date day, List<Order> orders, float revenue) {
- this.day = day;
- this.orders = orders;
- this.revenue = revenue;
- }
- public void sendToAdmin() {
- // Send report to admin logic
- }
- }
- // Staff and specific roles
- class Staff extends User {
- private float yearsOfExperience;
- private boolean isOnline;
- public Staff(int id, String fullName, String address, String username, String password, float yearsOfExperience) {
- super(id, fullName, address, username, password);
- this.yearsOfExperience = yearsOfExperience;
- this.isOnline = false;
- }
- public void changeOrderStatus(Order order, String newStatus) {
- order.setStatus(newStatus);
- }
- }
- class Courier extends Staff {
- private boolean isDelivering;
- public Courier(int id, String fullName, String address, String username, String password, float yearsOfExperience) {
- super(id, fullName, address, username, password, yearsOfExperience);
- this.isDelivering = false;
- }
- public void takeOrder(Order order) {
- this.isDelivering = true;
- // Logic to handle order delivery
- }
- public void deliverOrder(Order order) {
- this.isDelivering = false;
- // Logic to finalize order delivery
- }
- }
- class CustomerSupporter extends Staff {
- private boolean isOnSupport;
- public CustomerSupporter(int id, String fullName, String address, String username, String password, float yearsOfExperience) {
- super(id, fullName, address, username, password, yearsOfExperience);
- this.isOnSupport = false;
- }
- public void answerUser(User user) {
- // Answers will be here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement