Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

COLLEGE OF COMPUTING, INFORMATICS AND MEDIA

UNIVERSITI TEKNOLOGI MARA


MERBOK, KEDAH

CSC305 PROGRAMMING PARADIGMS


PROJECT TITLE: BOOK THRIFT SYSTEM

PREPARED BY:

NAME MATRIC NO.

AMIRA ADILAH BINTI ROZAIMAN 2021894822

KHAIRUN NAZIFAH BINTI ZAKARIA 2021493102

MUHAMMAD AKMAL ZUHAIR BIN MUHAMAD YUSRI 2021880766

SITI NUR HAWA BINTI AZRIN 2021842354

GROUP:
KCS1104A

PREPARED FOR:
MADAM JASMIN ILYANI BINTI AHMAD

DATE OF SUBMISSION:
22 JULY 2023
TABLE OF CONTENT

NO CONTENT PAGE

1.0 Introduction
1.1 Case Study
1 1.2 About Project 1–2
1.3 Problem Statement
1.4 Objectives

2.0 Suggestion Solution


2.1 C Language
2.1.1 Array
3 – 16
2.1.2 List of Functions
2.1.3 Source Code
2 2.1.4 Sample Input and Output

2.2 Java Language


2.2.1 Class Diagram
17 – 37
2.2.2 Source Code
2.2.3 Sample Input and Output

3 3.0 Conclusion 38
1.0 INTRODUCTION
1.1 Case Study
After careful consideration and discussions, the decision has been made to develop a
computerized book thrift system for this semester's project. The system, named the "Book
Thrift System," will be implemented using the C and Java programming languages. By utilizing
their respective features and functionalities, we aim to create a comprehensive website that is
both user-friendly and efficient.

The system will encompass details like titles, authors, genres, conditions, and prices. By
harnessing the power of C programming language, we will design and implement functions
specifically crafted for adding, deleting, editing, and modifying book entries within the
database. These efficient functions ensure accurate management of book records while
maintaining user-friendly accessibility.

By combining the strengths of C and Java, our team is dedicated to developing a reliable and
efficient Book Thrift Management System that prioritizes user satisfaction while minimizing
errors. This innovative system aims to advance practices in managing book thrift with its
efficiency, and user-friendly interface.

Through this project, our aim is to provide a dependable and innovative solution that caters to
the needs of both book enthusiasts and bargain hunters. The Book Thrift System functions as
a platform dedicated to facilitating efficient operations within the book thrift community, thereby
fostering its growth and advancement.

1.2 About Project


The Book Thrift system is an online bookstore that provides access to make a purchase of
books at affordable prices. The focus of this project is to streamline the process selling thrift
books available on their platform in a swift and systematic manner. Furthermore, the system
offers discounted and cos-effective options for customers to purchase out-of-print books.

1
1.3 Problem Statement
The customer may face difficulty while making an online book purchase:

• Lack of an online commerce platform: The absence of a developed and implemented


Book Thrift online commerce platform hinders customers from accessing the book
purchasing process conveniently.
• Inefficient book purchasing process: The current book purchasing process does not
provide an excellent experience for customers, resulting in a subpar experience when
purchasing quality books at a reasonable and affordable price.
• Ineffective inventory management: The existing inventory management systems fail to
effectively track, update, and display the available books, making it difficult to provide
customers with accurate and up-to-date information.
• Non-user-friendly interface: The current interface lacks user-friendliness, creating
challenges for customers to manage their purchases and books smoothly, which impacts
their overall experience.

1.4 Objective

• To develop and implement Book Thrift online commerce.


• To offer an excellent book purchasing process of quality books with reasonable and
affordable prices.
• To develop effective inventory management systems to keep track of and display the
books that are available.
• To develop a user-friendly interface so that the customers can manage their purchases
smoothly.

2
2.0 Suggestion Solution
2.1 C Language
2.1.1 Array
Arrays are used to store and manage information of book thrift system.

• struct Book books[MAX_BOOKS]: Array of structures to store details about different


books available in the Book Thrift System.

• struct Book cart[MAX_BOOKS]: Array of structures to serve as the shopping cart for
the customer, storing books added to the cart.

• char searchGenre[MAX_GENRE_LENGTH]: Array of characters to store the genre that


the customer wants to search for (Fiction or Non-Fiction).

• char customer.name[MAX_NAME_LENGTH]: Array of characters to store the name of


the customer for delivery details.

• char customer.phone[MAX_PHONE_LENGTH]: Array of characters to store the phone


number of the customer for delivery details.

• char customer.address[MAX_ADDRESS_LENGTH]: Array of characters to store the


address of the customer for delivery details.

These arrays are essential components of the Book Thrift System. They help in organizing
and managing book details, shopping cart items, user inputs, and customer information,
allowing the program to efficiently handle and display data for book purchases and deliveries.

3
2.1.2 List of Functions
This code has few lists of functions that perform specific tasks. These features improve the
readability and modularity of the code.

void displayBookDetails(const A function that displays the details of a given book,


struct Book* book) including its title, author, genre, and price.

void addToCart(struct Book* A function that adds a book to the shopping cart. It
cart, int* cartSize, const struct takes the cart array, the cart size, and the book to be
Book* book) added as input parameters.

void removeFromCart(struct A function that removes a book from the shopping


Book* cart, int* cartSize) cart. It takes the cart array and the cart size as input
parameters and prompts the user to choose the book
to remove.

float calculateTotal(const struct A function that calculates the total price of all books in
Book* cart, int cartSize, int the shopping cart. It takes the cart array, cart size, and
hasMembership) a flag indicating whether the customer has a
membership as input parameters and returns the total
price as a floating-point number.

void getCustomerDetails(struct A function that prompts the user to enter their details
Customer* customer) for delivery. It takes a pointer to the Customer
structure as an input parameter and stores the
entered name, phone number, and address in the
structure.

void displayReceipt(const A function that displays a receipt for the customer's


struct Book* cart, int cartSize, purchase. It takes the cart array, cart size, customer
const struct Customer* details, and the total price as input parameters and
customer, float total) prints a formatted receipt with all the information.

int main() The main function provides a menu-driven interface


for the user to interact with the Book Thrift System. It
allows the user to search for books, add books to the
cart, edit the cart, and finalize the purchase.

These functions improve code organization and readability by breaking down the main tasks
of the program into smaller, modular functions. Each function handles a specific aspect of the
Book Thrift System, making the code easier to understand and maintain.

4
2.1.3 Source Code

5
6
7
8
2.1.4 Sample of Input and Output
• The program will display list of books that available at Book Thrift for them to buy.
• The customer will choose to search books from either fiction genre or non-fiction genre.

9
• The program will display books from the genre chosen by user one by one.
• The user will input 1 if they want to add the book into cart, input 0 if they do not want to.
• Until the books in the genre picked by user finish being listed, the system will ask user
whether they want to search again.

10
• If the user input 1, the program will ask again the book genre the user want to search for.
• The same process repeated until the program finish listing the books in the genre chosen
by user.

11
• Assuming the user finished going through list of books, the user will input 0 which is stop
searching.
• The program will ask the user to input the delivery details which includes their name, phone
number, and delivery address.
• After the user give their details to the program, it will ask if the user have membership or
not, and if they do, which input is 1, the program then will calculate the total purchase
amount with a 10% off than normal price.
• The program then will display the cart contents, which display the books the user added to
cart from the previous process.
• The program will ask user whether they want to confirm the purchase or edit the cart.

12
• If the user chooses to edit the cart which the input is 2, then the program will ask whether
to add books (1), delete books (2), or cancel editing (0).
• If the user chooses to add books, the program will list all books available in Book Thrift,
and ask user to choose which book by inputting the index number of the book.

13
• After adding the book into cart, the program will display again the updated list of cart
contents.
• Then, the program will ask whether to confirm purchase or edit cart.

14
• If the user chose to edit cart, then the program will ask if the user want to add book,
remove book, or cancel editing.
• If the user chose to remove book, which input is 2, the program will ask the user to input
the index number of the book that the user want to remove based on the latest list of cart
contents.

15
• If the user chose to confirm purchase, which input is 1, the program then will display
the receipt of purchase.
• The receipt consists of the user delivery details, list of books purchased, and the total
amount of purchase made by user.

16
2.2 Java Language
2.2.1 Class Diagram
An object-oriented system's static structure and interactions between classes can be seen in
class diagrams. It gives a general overview of the classes, along with their characteristics and
relationships. It's crucial to remember that the provided code does not specifically define any
class relationships or inheritance, therefore the class diagram will mostly concentrate on the
individual classes and their characteristics.

The "Book Thrift System" class diagram can be represented as follow:

Figure 2.2: Book Thrift System Class Diagram.

17
• A book is represented by the book class, which includes details about its title, author,
genre, and price. To print the book details, it also offers a method called
displayBookDetails().
• A customer's name, phone number, and address are represented by the customer class.
It has a constructor to set up the consumer's information.
• The main class, that contains the main method and acts as the program's entry point, is
the BookThriftSystem class. It includes multiple static methods for handling the cart and
displaying the receipt in addition to constants like MAX_BOOKS, MAX_TITLE_LENGTH,
etc.

Method used in this program, as the table below.

addToCart(Book[] cart, • This method adds a book to the cart (an array of books) by taking the
int cartSize, Book book) current cart, its size, and the book to be added as input. It returns an
updated cart with the new book.
removeFromCart(Book[] • This method removes a book from the cart. When a book is removed
cart, int cartSize) from the cart, the array elements are shifted, effectively updating the
cart without the selected book.

In both cases, the cart is updated based on the user's actions. If a book
is added or removed, the cart array is modified accordingly, and this
represents the idea of updating the cart.
calculateTotal(Book[] • This method calculates the total price of the books in the cart. It takes
cart, int cartSize, int the cart, its size, and a flag (1 or 0) indicating whether the customer
hasMembership) has a membership or not. It adds up the prices of all books in the cart
and applies a 10% discount if the customer has membership.
getCustomerDetails() • This method collects the customer's details (name, phone number,
and address) for delivery. It prompts the user to input these details
and returns a customer object with the entered information.
displayReceipt(Book[] • This method displays the receipt of the purchased books and the
cart, int cartSize, customer's details. It takes the cart, its size, the customer object, and
Customer customer, float the total price as input. It prints the customer's information and then
total) lists the details of the books in the cart, along with their prices. Finally,
it displays the total price.
main(String[] args) • This is the entry point of the program where the execution starts. It
sets up the initial book and cart arrays, allows the user to search for
books based on genre, add books to the cart, and edit the cart. It also
calculates the total price, displays the receipt, and thanks the
customer for the purchase

The properties and methods are shown in the class diagram together with their respective
data types and visibility (public or private). Public visibility is indicated by the "+" and private
visibility by the "-".

18
2.2.2 Source Code
Class: Book

19
Class: Customer

20
Class: BookThriftSystem (main class)

21
22
23
24
25
2.2.3 Sample Input and Output
• Users will be displaying the list of books that are available for sale in the system.
• Then the user can search the book based on genre by entering fiction or non-fiction in
the text field to display the available book before adding to their cart.

26
27
• If the user insert fiction, the display book of fiction genre will be display and the user
needs to enter 1 to add the book to the cart. 0 for skip and display another book of
fiction genre.
• After finish displaying all available fiction book, the system will ask if the user wants to
choose 1 to search a book again or 0 for No.
• If the user enters 1 to search for a book again, the same process will be repeated.

28
• If the user enters 0 for No, the system will proceed to ask the customer details for delivery
used as follows.
• The system will also ask for membership for 10% off for every book purchased. 1 for yes
and 0 for No. If no, the total price will be counted without any 10% discount.

Then the system will display the customer cart and the system will proceed to ask the user:

• 1 to confirm the purchase.


• 2 to edit the cart.
• 0 to cancel order.

29
If the user enters 1 to confirm purchase the receipt output will be displayed as follows:

30
If the user enters 2 for edit cart, user can choose whether to

• 1 to add another book.


• 2 to delete book from cart.
• 0 to cancel.

31
If the user enters 1 to add books, the system will display all the books for each genre and
ask to enter the books index to add to the cart.

32
33
After entering the book index, the system will display the cart first before ask for confirmation.

• 1 to confirm purchase and proceed to add the book into cart.


• 2 to edit cart.
• 0 to cancel.

34
If the user enters 1 to confirm the purchase, the new book index will be added into the cart
and the system will proceed to count the total price and display receipt as follow:

35
If the user enters 2 for deleted books, the system will display the customer’s cart and the
user needs to enter.

• the books index from the cart to proceed delete the books from cart.
• 0 for cancel.

36
Then the recent cart will be display and the same process will be asked until the customer
satisfies with their purchased

If the user enters 0 to cancel, the purchase will be cancelled.

37
3.0 CONCLUSION

In conclusion, the Book Thrift system has been successful in creating an online bookstore that
gives customers access to inexpensive books, with a specific focus on effectively selling
secondhand books. Additionally, the system offers discounted options for buying out-of-print
books, which increases its appeal to book lovers looking for rare editions. However, the system
should put easy readability for users first in order to further enhance the user experience. The
process of choosing a book could be made simpler by implementing user-friendly features like
clear categorization with just two main categories (Fiction and Non-Fiction). Additionally, a
more efficient and satisfying shopping experience would result from improving the search
functionality and incorporating user reviews and recommendations. With these upgrades,
Book Thrift can solidify its position as a dependable and practical platform for buying
inexpensive and exclusive books.

38

You might also like