-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,19 @@ | ||
package org.example; | ||
|
||
import java.io.*; | ||
import java.time.*; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.*; | ||
|
||
public class Rent extends UniqueID{ | ||
Book book; | ||
User user; | ||
public class Rent { | ||
Book book ; | ||
User user ; | ||
LocalDateTime currentDateTime = LocalDateTime.now(); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
private final String RentalDate; | ||
private final String RentalDate ; | ||
public String getRentalDate() { return RentalDate; } | ||
public Rent(){ | ||
book = new Book(); | ||
user = new User(); | ||
public Rent() | ||
{ | ||
RentalDate = currentDateTime.format(formatter); | ||
} | ||
public void RentBook(String name) { | ||
for (int i = 0; i < book.getTotal().size(); i++) | ||
{ | ||
String[] list = book.getTotal().get(i).split("/"); | ||
if (Objects.equals(list[1],name) || Objects.equals(list[4],"true")) | ||
{ | ||
book.getTotal().remove(i); | ||
System.out.println("The book has been successfully rented."); | ||
System.out.println("enjoy , Bye."); | ||
String temp = list[0] + "/" + list[1] + "/" + list[2] + "/" + list[3] + "/" + RentalDate ; | ||
book.getTotal().add(temp); | ||
break; | ||
} | ||
} | ||
} | ||
public void ReturnBook(String name) { | ||
for (int i = 0; i < book.getTotal().size(); i++) | ||
{ | ||
String[] list = book.getTotal().get(i).split("/"); | ||
if (Objects.equals(list[1],name)) | ||
{ | ||
book.getTotal().remove(i); | ||
System.out.println("Thank you for returning the book"); | ||
String temp = list[0] + "/" + list[1] + "/" + list[2] + "/" + list[3] + "/" + "true" ; | ||
book.getTotal().add(temp); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters