Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Assignment No.

02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

Please read the following instructions carefully before solving & submitting assignment:

Uploading Instructions:
 You are not allowed to use any other software/IDE except NetBeans IDE for this assignment
development.
 The submission must be a complete NetBeans IDE project folder (which should contain complete source
code, Java files, database file and builds etc.). After finalizing, compress it with Zip or RAR format, save
with your own Student ID (e.g. bc000000000.zip) and submit it at VU-LMS within due date.
 Your assignment should be in .zip /.rar format. Other file formats will not be accepted.
 No assignment will be accepted through email.

Rules for Marking:


It should be clear that your assignment will not get any credit if:

o The assignment is submitted after due date.


o The assignment is not submitted in .zip /.rar format.
o The submitted assignment does not open or file is corrupted.
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet,
strict disciplinary action will be taken in this case.
o The submitted code is unable to compile/execute in NetBeans IDE during evaluation, submitted code
will be checked on NetBeans IDE. If unable to execute then ZERO marks will be awarded and no
excuses will be accepted in this regard.

Note: Do not put any query on MDB regarding this assignment, If you face any type of issue while uploading
assignment on LMS, then you should mail your assignment along with screen shot of error within due date to
cs506@vu.edu.pk.

Lectures Covered: This assignment covers Lecture # 10-17

GOOD LUCK

1
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

Problem Statement:
You are required to write a Java program, named BookShop, to purchase online CS506 course’s helping
material. In this program a user can add and remove items to the BookShop Cart. The program will calculate
the total bill as the items are added or removed from shopping cart and will display the amount via user
friendly interface on real time basis. All orders will be saved in MS Access database so that the administrator
could process the orders properly.

Detailed Description:
At start, your program will display a GUI (i.e. Graphical User Interface) which should contain options for
selecting quantity of products, sample is given in Figure 1.

Fig. 1: BookShop Cart GUI

Here, the customer can select the quantity (i.e. 0 to 10) for available products by clicking on add (+) or
remove (–) buttons. Sample is given in Figure 2.

2
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

Fig. 2: BookShop Cart GUI

The cart should be updated on each action and correct amount after calculating the number of items, subtotal,
shipping charges (shipping charges are given below) and grand total should be displayed. Sample is given in
Figure 3.

Fig. 3: BookShop Cart GUI

3
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

When user clicks on "Place Order" then the program should check whether the cart contains any item or not.
If cart is empty, then a message "Cart is empty!" should be displayed. Sample is given in Figure 4.

Fig. 4: Cart is Empty

Otherwise, order details will be saved to MS Access database file and interface will be updated with initial
values (i.e. zero quantity for each item and zero in amount fields etc.) as well. Sample is given in Figure 5.

Fig. 5: Order placed successfully & values got reset

4
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

Further, cross icon at top right corner of the interface should terminate the program and show the developer
information (i.e. Student Id and name) via message dialog.

Fig. 6: Developer Info


Required Stuff:
Java Classes:
Product.java:
• id: int
• name: String
• price: float
• quantity: int
• Constructors: default and parameterized constructor
• Standard Setters: setId(…), setName(…), setPrice(…),
setQuantity(…)
• Standard Getters: getId(), getName(), getPrice(),
getQuantity()

Cart.java
• cartItems: ArrayList
• Constructors: default constructor
• Member Functions: addItem(…), removeItem(…),
getItemsList(), emptyCart(), getProductIndex(…),
getQuantity(…)

DatabaseHelper.java (should contain all database related code)


• FILE: String
• Member Functions: getConnectionStatement(…), addOrder(…),
fetchProductsData(…)

5
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

BSCartGUI.java (Contains GUI Code)


• Data Members: All Required
• Constructors: default
• Member Functions: updateStatus(…), updateBill(), addOrder(),
developerInfo(), All Event Handling Functions

BookShop.java (should contain Main method)

Database file:
BSxxxxxxxx.accdb (must be same as your own VU student id)

Note: Need to put database file in assets folder in NetBeans project directory as shown below.

Fig. 3: Folder "assets" in NetBeans project directory

Sample Data:
# Item Price (Rs)
1 Handouts 500.0
2 Reference Book 500.0
3 DVD 500.0
4 USB 2500.0
Tab. 1: Sample Products Data

# No of Items Shipping Charges (Rs)

6
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

1 0 0
2 1 to 5 50.0
3 6 to 10 100.0
4 11 to 15 150.0
5 16 to 20 200.0
6 21 to 25 250.0
7 26 to 30 300.0
8 31 to 35 350.0
9 More than 35 400.0

Tab. 2: Sample Shipping Charges

Tab. 3: Products Table in MS Access Database file

Tab. 4: Orders Table in MS Access Database file

Important Things to Implement:

7
Assignment No. 02
Total Marks: 20
Semester: Fall 2020 Due Date: 16/12/2020
CS506 – Web Design and Development

 For GUI, relevant components (i.e. JFrame, JPanel, JButton, JTextField and JLable etc.) from AWT
and Swing packages should be used.
 You will have to use ucanaccess driver to connect to MS Access database. In this case, you are
suggested to view the video tutorial having title “A video tutorial for installation of UCanAccess
Driver.” by downloading it from downloads section of CS506 course.
 For storing/fetching data to/from database, you will need to use proper SQL queries.
 You can use same Product and Cart Java classes as provided in assignment # 1 and also can make
changes as required.
 Java classes must have proper Data Members and Member Functions along with Constructors,
Standard Setters and Getters etc.
 Need to make sure that exceptions are managed properly throughout the program; especially
NullPointerException, ClassNotFoundException and SQLException.
 All images, tables and sample data, given in this document, are just for reference purpose only. You
have to provide your own implementations. It is not required to be exactly the same.

Good Luck

You might also like