-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx04_Libraries.java
More file actions
61 lines (50 loc) · 1.35 KB
/
Ex04_Libraries.java
File metadata and controls
61 lines (50 loc) · 1.35 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.company;
import java.util.Arrays;
class library{
String [] books;
int noOfBooks;
library (){
this.books = new String[50];
this.noOfBooks = 0;
}
void addBook(String b){
this.books [noOfBooks]= b;
noOfBooks++;
System.out.println(b + " book has been added in the library");
}
void availableBooks(){
System.out.println("List of books has been available in the library");
for (int i=0; i<books.length; i++){
if (books[i]==null){
continue;
}
System.out.println(books[i]);
}
}
void issueBooks(String b){
for (int i=0; i<this.books.length; i++){
if (this.books[i].equals(b)){
this.books[i]=null;
System.out.println(b + " book has been issued by you");
break;
}
}
}
void returnBooks(String b){
addBook(b);
System.out.println(b + " book has been returned");
}
}
public class Ex04_Libraries {
public static void main(String[] args) {
library l = new library();
l.addBook("C++");
l.addBook("Java");
l.addBook("C");
l.availableBooks();
l.issueBooks("Java");
l.availableBooks();
l.returnBooks("Java");
l.availableBooks();
}
}