-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooks.java
More file actions
38 lines (35 loc) · 1.06 KB
/
Books.java
File metadata and controls
38 lines (35 loc) · 1.06 KB
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
33
34
35
36
37
38
/*
* This class include the sub class of Books from Abstract class Catelogltem
* The book class allow main menu to create an object of books
*/
package bookstoresystem;
//subclass of Catelogltem
import java.math.BigDecimal;
public class Books extends Catelogltem{
//set variables
private String booksAuthor;
private int booksISBN;
//constructor
public Books(String title, double price, String author, int ISBN){
super(title, price);
booksAuthor = author;
booksISBN = ISBN;
this.price=price*0.9;
BigDecimal bg = new BigDecimal(this.price);
this.price = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
//return author name
public String getAuthor(){
return booksAuthor;
}
//return the ISBN number
public int getISBN(){
return booksISBN;
}
//over ride the string
@Override
public String toString(){
String str = "Title:\t" + title + "\t|" + "Author:\t"+booksAuthor+"\t|"+"Price: $"+price+"\t|"+" ISBN:"+booksISBN;
return str;
}
}