-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx07_Library2.java
More file actions
45 lines (38 loc) · 1.46 KB
/
Ex07_Library2.java
File metadata and controls
45 lines (38 loc) · 1.46 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
package com.company;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
class Library2 {
HashSet<String> books = new HashSet<>();
Calendar c = Calendar.getInstance();
Date d = new Date();
void availableBooks() {
System.out.println("Available books in the library: " + books);
}
void addBooks(String a,String name) {
books.add(a);
System.out.println("Added by " +name + a + " book, in the Library at " + d.getDate() + "/" + d.getMonth() + " " + Calendar.HOUR + ":" + Calendar.MINUTE);
}
void issueBooks(String b, String name) {
books.remove(b);
System.out.println("Issued " + b + " by " + name + " from the Library at " + d.getDate() + "/" + d.getMonth() + " " + Calendar.HOUR + ":" + Calendar.MINUTE);
}
void returnIssuedBooks(String a, String name) {
books.add(a);
System.out.println("Returned by" + name + " from the Library at " + d.getDate() + "/" + d.getMonth() + " " + Calendar.HOUR + ":" + Calendar.MINUTE);
}
}
public class Ex07_Library2 {
public static void main(String[] args) {
Library2 l = new Library2();
l.addBooks("Java", "Abhay");
l.addBooks("Kotlin", "Abhay");
// l.addBooks("C", "Abhay");
// l.addBooks("Python", "Abhay");
// l.addBooks("C++", "Abhay");
l.availableBooks();
l.issueBooks("Java" , "Abhay");
l.availableBooks();
}
}