-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathStore.java
32 lines (27 loc) · 936 Bytes
/
Store.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*Create Exception class called BookQuantityNotAvailableException and use it in the
class called “Store” which is described by its bookId title, author, price and
quantityAvailable. Include a method called purchase() taking the purchase quantity as
a parameter and update the quantityAvailable appropriately. Create a package
containing the Store and a Exception class. Write a java program to test the working
of the Store class.*/
import Library.Book;
public class Store {
public static void main(String args[]) {
Book b1 = new Book();
b1.id = "1";
b1.title = "Harry Potter";
b1.author = "JKR";
b1.price = 250;
b1.quant = 10;
try {
b1.purchase(11);
} catch (Exception e) {
System.out.println(e);
}
try {
b1.purchase(9);
} catch (Exception e) {
System.out.println(e);
}
}
}