Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
Binary file not shown.
18 changes: 18 additions & 0 deletions Answers/40230112013/Library Management System/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

## Folder Structure

The workspace contains two folders by default, where:

- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the `bin` folder by default.

> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.

## Dependency Management

The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions Answers/40230112013/Library Management System/src/Admin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Admin extends User {
public Admin(String name, String surname, String phoneNumber, String userId, String password) {
super(name, surname, phoneNumber, userId, password);
}

static final String Adminpass = "e";


}
174 changes: 174 additions & 0 deletions Answers/40230112013/Library Management System/src/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import java.io.IOException;
import java.util.*;

public class App {
public static void main(String[] args) throws IOException {
try (Scanner scanner = new Scanner(System.in)) {
int i = 1;
while (i == 1) {
Cli.start();
switch (scanner.nextInt()) {
case 1:
i = 1;
User us = Cli.avardanuser();
if (us != null) {
Cli.adps();
String s = scanner.next();
if (s.equalsIgnoreCase(Admin.Adminpass)) {
while (i == 1) {
Cli.adminList();
int j = scanner.nextInt();
switch (j) {
case 1:
Library.addBook(Cli.getBook());
System.out.println("*********************\nanjam shod");
break;
case 2:
Library.showBook();
break;
case 3:
Library.showUser();
break;
case 4:
Cli.bfind();
String h = scanner.next();
List<Book> l = Book.bookfinder(h);
int o=100;
if(l.size()==0){
System.out.println("yaft nshd ");
break;
}
Cli.gh();
while (o>l.size()) {
o = scanner.nextInt();
}
o--;
Cli.rentday();
boolean ax = true;
if (ax == true) {
Library.rentBook(l.get(o), us, scanner.nextInt());
ax = false;
}
break;
case 5:
Library.returnBook(us);
break;
case 6:
Library.removeUser(us);
System.exit(0);
break;
case 7:
Cli.bfind();
String ui = scanner.next();
List<Book> hg = Book.bookfinder(ui);
if(hg.size()==0){
System.out.println("yaft nshd ");
break;
}
Cli.gh();
int po=100;
while (po>hg.size()) {
po = scanner.nextInt();
po--;
}

Library.removeBook(hg.get(po));
System.out.println("anjam shod");
break;
case 8 :
Cli.getHours();
Cli.getCapacity();
break;
case 9:
System.exit(0);
break;
default:
break;
}
Cli.edame();
i = scanner.nextInt();
}
} else {
System.out.println("admin pass is incorrect");
}
} else
System.out.println("admin not found");
break;
case 2:
i = 1;
User uk = Cli.avardanuser();
if (uk != null) {
while (i == 1) {
Cli.userList();
int j = scanner.nextInt();
switch (j) {
case 1:
Library.addBook(Cli.getBook());
System.out.println("*******************\nanjam shod");
break;
case 2:
Book.bookfinder("o");
break;
case 3:
Cli.bfind();
String h = scanner.next();
List<Book> l = Book.bookfinder(h);
int o=100;
if(l.size()==0){
System.out.println("yaft nshd ");
break;
}
Cli.gh();
while (o>l.size()) {
o = scanner.nextInt();
}
o--;
Cli.rentday();
boolean ax = true;
if (ax == true) {
Library.rentBook(l.get(o), uk, scanner.nextInt());
ax = false;
}
break;
case 4:
Library.returnBook(uk);
break;
case 5:
Cli.getCapacity();
Cli.getHours();
break;
case 6:
System.exit(0);
case 7:
Library.removeUser(uk);
System.exit(0);
break;
default:
break;
}
}
} else
System.out.println("user not found");
break;
case 3:
User user = Cli.rgistr();
Library.addUser(user);
System.out.println("anjam shod");
break;
case 4:
System.exit(0);
break;
default:
System.out.println("Na motabar");
break;
}
Cli.edame();
try {
i = scanner.nextInt();
} catch (Exception e) {
break;
}
}
}
}
}
76 changes: 76 additions & 0 deletions Answers/40230112013/Library Management System/src/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import java.util.*;

public class Book {
private String bookID;
private String title;
private String author;
private boolean isAvailable;
private String description;

public Book(String title, String author, String description) {
this.bookID = UUID.randomUUID().toString();
this.title = title;
this.author = author;
this.description = description;
this.isAvailable = true;
}

public String getBookID() {
return bookID;
}

public void setTitle(String title) {
this.title = title;
}

public String getTitle() {
return title;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public boolean isAvailable() {
return isAvailable;
}

public void setAvailable(boolean available) {
isAvailable = available;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
public String toString1() {
return "Book{" +
"bookID='" + bookID + '\'' +
", title='" + title + '\'' +
", author='" + author + '\'' +
", isAvailable=" + isAvailable +
", description='" + description + '\'' +
'}';
}
public static List<Book> bookfinder(String t) {

List<Book> me = Library.getrepo();
List<Book> b = new ArrayList<Book>();
int i=1;
for (Book u : me) {
if(u.toString1().contains(t)){
System.out.println(i +"_" + u.toString1());
b.add(u);
i++;
}
}
return b;
}
}
Loading