yeeeee
California, United States
 
 
︻̷̿┻̿═━一 YOU JUST GOT SNIPED!
Sin conexión
Juego favorito
==================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();
}
}
Actividad reciente
456 h registradas
usado por última vez el 26 ENE
64 h registradas
usado por última vez el 12 ENE
39 h registradas
usado por última vez el 21 DIC 2024
Comentarios
只给原神玩家杀 23 ENE 2019 a las 1:49 a. m. 
good boy
Ryanx3000 4 AGO 2017 a las 6:45 p. m. 
badge
CopyypoC 8 MAY 2016 a las 1:41 p. m. 
d,':^)
♥♥♥.
Chewie 1 SEP 2015 a las 4:52 p. m. 
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 a las 9:15 a. m. 
+rep for being kool
Primordial Bob 12 JUN 2014 a las 8:47 a. m. 
+rep nice and friendly trader