yeeeee
California, United States
 
 
︻̷̿┻̿═━一 YOU JUST GOT SNIPED!
Currently Offline
Favorite Game
21
Hours played
38
Achievements
==================Library.Java==================
public class Library {
String address;
java.util.ArrayList<Book> books;

public static final String openTime = "9am";
public static final String closeTime = "5pm";

public Library(String libraryAddress) {
address = libraryAddress;
books = new java.util.ArrayList<Book>();
}

public void addBook(Book book) {
books.add(book);
}

public static void printOpeningHours() {
System.out.println("Libraries are open daily from " + openTime + " to " + closeTime);
}

public void printAddress() {
System.out.println(address);
}

public void printAvailableBooks() {
boolean bookPresent = false;
for (Book book : books) {
if (!book.isBorrowed()) {
System.out.println(book.getTitle());
bookPresent = true;
}
}
if (!bookPresent) {
System.out.println("No book in catalog");
}
}

public void borrowBook(String title) {
int found = 0;
for (Book book : books) {
if (book.getTitle().equals(title)) {
if (found == 0) {
found = 1;
}
if (!book.isBorrowed()) {
book.borrowed();
found = 2;
break;
};
}
}
if (found == 0) {
System.out.println("Sorry, this book is not in our catalog.");
} else if (found == 1) {
System.out.println("Sorry, this book is already borrowed.");
} else if (found == 2) {
System.out.println("You successfully borrowed " + title);
}
}

public void returnBook(String title) {
boolean found = false;
for (Book book : books) {
if (book.getTitle().equals(title) && book.isBorrowed()) {
book.returned();
found = true;
break;
}
}
if (found) {
System.out.println("You successfully returned " + title);
}
}

public static void main(String[] args) {
// Create two libraries
Library firstLibrary = new Library("10 Main St.");
Library secondLibrary = new Library("228 Liberty St.");

// Add four books to the first library
firstLibrary.addBook(new Book("The Da Vinci Code"));
firstLibrary.addBook(new Book("Le Petit Prince"));
firstLibrary.addBook(new Book("A Tale of Two Cities"));
firstLibrary.addBook(new Book("The Lord of the Rings"));

// Print opening hours and the addresses
System.out.println("Library hours:");
printOpeningHours();
System.out.println();

System.out.println("Library addresses:");
firstLibrary.printAddress();
secondLibrary.printAddress();
System.out.println();

// Try to borrow The Lords of the Rings from both libraries
System.out.println("Borrowing The Lord of the Rings:");
firstLibrary.borrowBook("The Lord of the Rings");
firstLibrary.borrowBook("The Lord of the Rings");
secondLibrary.borrowBook("The Lord of the Rings");
System.out.println();

// Print the titles of all available books from both libraries
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
System.out.println();
System.out.println("Books available in the second library:");
secondLibrary.printAvailableBooks();
System.out.println();

// Return The Lords of the Rings to the first library
System.out.println("Returning The Lord of the Rings:");
firstLibrary.returnBook("The Lord of the Rings");
System.out.println();

// Print the titles of available from the first library
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
}
}
Recent Activity
452 hrs on record
last played on 26 Jan
64 hrs on record
last played on 12 Jan
39 hrs on record
last played on 21 Dec, 2024
Comments
只给原神玩家杀 23 Jan, 2019 @ 1:49am 
good boy
Ryanx3000 4 Aug, 2017 @ 6:45pm 
badge
CopyypoC 8 May, 2016 @ 1:41pm 
d,':^)
♥♥♥.
Chewie 1 Sep, 2015 @ 4:52pm 
YOU’VE BEEN HIT BY THE

|^^^^^^^^^^^^](ノ◕ヮ◕)ノ*:・゚✧
|KAWAII TRUCK | ‘|”“”;.., ___.
|_…_…______===|= _|__|…, ] |
............”(@ )’(@ )”“”“*|(@ )(@ )*****(@

♥♥♥♥♥♥♥♥♥♥♥♥ ONCE U BEEN HIT, U HAVE TO HIT 8 ♥♥♥♥♥♥♥ KAWAII ASS PEOPLE. IF YOU GET HIT AGAIN YOU’LL KNOW YOUR REALLY SO ♥♥♥♥♥♥♥ KAWAII IT'S SO ♥♥♥♥♥♥♥ SUGOI PEOPLE WILL PISS THEIR PANTS AND ♥♥♥♥ BRICKS AND YOU WILL BE THE ♥♥♥♥♥♥♥♥♥♥♥♥♥ LORD OF THE ♥♥♥♥♥♥♥♥♥♥♥♥♥ KAWAII! IF YOU BRAKE DIS ♥♥♥♥♥♥♥♥♥♥♥♥♥ CHAIN, YOULL BEE CURSED WITH UN*KAWAIINESS AND ♥♥♥♥♥♥♥♥♥ FOR 9000 YEARS SO PAS EET; HIT WHO EVER YOU THINK IS KAWAII

We are Tomodachi.
We Ride Together.
We Die Together.
barkysharky 22 Jun, 2014 @ 9:15am 
+rep for being kool
Primordial Bob 12 Jun, 2014 @ 8:47am 
+rep nice and friendly trader