-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_51.java
More file actions
43 lines (43 loc) · 1.07 KB
/
Main_51.java
File metadata and controls
43 lines (43 loc) · 1.07 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
39
40
41
42
43
class Library{
String books[];
int numb;
Library(){
this.books=new String[100];
}
void addBook(String book){
this.books[numb]=book;
numb++;
System.out.println("book is added");
}
void showBook(){
System.out.println("Available books are:");
for (String book: this.books){
if (book==null)
continue;
System.out.println(book);
}
}
void issueBook(String book){
for (int i=0; i<this.books.length; i++){
if (this.books[i].equals(book)) {
System.out.println("book issued");
this.books[i] = null;
}
}
}
void returnBook(String book){
addBook(book);
}
}
public class Main_51 {
public static void main(String[] args) {
Library central=new Library();
central.addBook("kit");
central.addBook("pit");
central.showBook();
central.issueBook("kit");
central.showBook();
central.addBook("kit");
central.showBook();
}
}