-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBook (4).java
111 lines (88 loc) · 2.13 KB
/
Book (4).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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* Bookstore Tracking System
*
* This Java program serves as a bookstore tracking system. It allows users to perform
* various tasks related to managing a bookstore's inventory, such as adding new books,
* updating book information, and searching for books by author or price. The class includes
* initialization of variables, default and parametric constructor, getters and setters,
* and methods used in the main.
*
* Author: [Dalia Betinjaneh]
* Date: [Monday September 18th]
* Course: [COMP 249]
*/
public class Book {
// initialize the variables
private String title;
private String author;
private long ISBN;
private double price;
private int numBooks = 0;
private static int numBookscnt = 1;
// default constructor
public Book() {
title = "";
author = "";
ISBN = 0;
price = 0;
numBooks = numBookscnt;
numBookscnt++;
}
// getters
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public long getISBN() {
return ISBN;
}
public double getPrice() {
return price;
}
public int getNumBooks() {
return numBooks;
}
public static int getNumBookscnt() {
return numBookscnt;
}
// setters
public void setTitle(String title) {
this.title = title;
}
public void setAuthor(String author) {
this.author = author;
}
public void setPrice(double price) {
this.price = price;
}
public void setISBN(long ISBN) {
this.ISBN = ISBN;
}
public void setNumBooks(int numBooks) {
this.numBooks = numBooks;
}
public static void setNumBookscnt(int count) {
numBookscnt = count;
}
// parametric constructor
public Book (String t, String a, long i, double p){
title = t;
author = a;
ISBN = i;
price = p;
numBooks = numBookscnt;
numBookscnt++;
}
// Method that finds number of books
public static int findNumberOfCreatedBooks() {
return numBookscnt - 1;
}
public boolean equalsTo(Book b1, Book b2) {
return b1.ISBN==b2.ISBN && b1.price==b2.price;
}
public String toString() {
return "Book " + numBooks + "\nAuthor: " + author + "\nTitle: " + title + "\nISBN: " + ISBN + "\nPrice: $" + price + "\n";
}
}