Class assignment 02
Class assignment 02
Subject OOP
Assignment Class Assignment 02
Date Oct 09th , 2024
Submitted to:
Moderator Ms, Sajida Kalsoom
1|Page
ASSIGNMENT 02
“Mr. Books” is an online bookstore for all ages and interests. Mr. Books offers a wide range of
books, from bestsellers to rare collector's items. The bookstore also provides services such as book
recommendations, customer reviews, and personalized reading lists. As the lead software architect
at Mr. Books, you are tasked to create a class diagram for the online system by keeping in view the
following requirements: Books: There are different categories of books, such as FictionBook,
NonFictionBook, and ScienceFictionBook. Each book has a title, author(s), ISBN, and price.
Customers: Mr. Books customers can have a customer ID, name, and address. Reviews: Customers
can leave reviews for books. Each review has a rating and comments. Recommendations: The
system provides personalized book recommendations to customers based on their reading history.
Orders: Customers can place orders for books. The system should be able to store order ID, order
date, and the list of books ordered.
import java.util.ArrayList;
import java.util.List;
class books{
books(){
}
books(String t,String A,String isbn,double p){
this.title=t;
this.author=A;
this.ISBN=isbn;
this.price=p;
}
2|Page
void setTitle(String T){
this.title=T;
}
void setAuthor(String a){
this.author=a;
}
void setISBN(String isbn){
this.ISBN=isbn;
}
void setPrice(double p){
this.price=p;
String getTitle(){
return title;
}
String getAuthor(){
return author;
}
String getISBN(){
return ISBN;
}
double getPrice(){
3|Page
return price;
}
bookCategories(){
4|Page
}
class customers{
protected String name;
protected String ID;
protected String address;
protected books book;
customers(){
}
customers(String N, String ID,String address,books b){
this.name=N;
this.ID=ID;
this.address=address;
this.book=b;
}
}
void setID(String ID){
this.ID=ID;
}
void setAddress(String address){
5|Page
this.address=address;
String getName(){
return name;
}
String getID(){
return ID;
}
String getaddress(){
return address;
}
books getbooks(){
return book;
}
}
6|Page
class reviews extends customers{
protected int rating;
protected String comment;
String getComment(){
return comment;
}
int getrating(){
return rating;
}
// }
7|Page
public String toString(){
orders() {}
orders(String N, String ID, String address, String id, String date, List<books> bookordered,
books b) {
super(N, ID, address, b);
this.orderId = id;
this.date = date;
bookList = bookordered;
}
8|Page
this.date = date;
}
String getOrderId() {
return orderId;
}
String getDate() {
return date;
}
List<books> getBooksOrdered() {
return bookList;
}
class recommendation {
private orders order;
recommendation() {}
9|Page
recommendation(orders order) {
this.order = order;
}
books book1 = new books("The great book", "F. Scott Fitzgerald", "123456789", 20.99);
10 | P a g e
books book2 = new books("Sapiens", "Yuval Noah Harari", "987654321", 25.99);
]
List<books> orderedBooks = new ArrayList<>();
orderedBooks.add(book1);
orderedBooks.add(book2);
orders order = new orders("habib", "C123", "123 Main St", "O1001", "2024-10-13",
orderedBooks, book1);
System.out.println(order);
11 | P a g e
Class Diagram
12 | P a g e