HW1 2014 Java
HW1 2014 Java
Deadline: 15/5/2024
Create a JAVA program to model an Online Bookstore Management System. You will have 5
classes: Book, Customer, Order, Inventory, and BookstoreManagmentSystem.
● public Book(String title, String author, String isbn, double price, int quantity):
Constructor to initialize a new Book object with the given parameters.
● public void updateQuantity(int delta): Method to update the quantity of the book by
adding the given value.
● Getters: Methods to retrieve information about the book such as title, author, ISBN,
price, and quantity.
● @Override public String toString(): Method to provide a string representation of the
Book object.
Customer Class:
Order Class:
● public Order(List<Book> items): Constructor to initialize a new Order object with the
given list of items.
● private void calculateTotalPrice(): Method to calculate the total price of the order based
on the prices of the items.
● public void updateShippingStatus(String status): Method to update the shipping status
of the order.
● ShippingStatus= {Pending or Shipped}
● @Override public String toString(): Method to provide a string representation of the
Order object.
Inventory Class:
main(String[] args): Main method to test the functionality of the classes and methods. Testing
functionality such as adding books to the inventory, searching for books, creating a customer,
placing an order, updating shipping status, and viewing order history.
1. Add book
3. Find a book
Order placed:
Order updated:
● We can not create objects from interfaces, but we can create object from any class that
implements that interface.
hashMap.put(1, "One");
treeMap.put(3, "Three");
linkedHashMap.put(5, "Five");
-----------------------
arrayList.add("One");
linkedList.add("Three");
import java.util.*;
employeeMap.put(1, "Ali");
employeeMap.put(2, "Mona");
employeeIds.add(1);
employeeIds.add(2);
// Accessing values from the map using keys from the list
} }}
Good Luck