Skip to content

Instantly share code, notes, and snippets.

@sunnyeyez123
Created November 10, 2017 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnyeyez123/f32ae866d9414836e54dea3d74770c9a to your computer and use it in GitHub Desktop.
Save sunnyeyez123/f32ae866d9414836e54dea3d74770c9a to your computer and use it in GitHub Desktop.
A simple Library tool to help analyze completed books in a small, personal library
/* a simple Library tool to help analyze completed books in a small, personal library
*/
import java.util.HashMap;
public class Library{
public Library(){
}
public void getFinishedBooks(HashMap<String, Boolean> library){
if(library.size() <1){
System.out.println("It's empty!");
}else{
System.out.println("Here are the books you finished: ");
for(String book : library.keySet()){
if(library.get(book)){
System.out.println(book);
}
}
}
}
public void getUnfinishedBooks(HashMap<String, Boolean> library){
if(library.size() <1){
System.out.println("It's empty!");
}else{
System.out.println("Here are the books you didn't finish: ");
for(String book : library.keySet()){
if(!library.get(book)){
System.out.println(book);
}
}
}
}
public static void main(String[] args){
HashMap<String, Boolean> myBooks = new HashMap<String, Boolean>();
myBooks.put("Road Down The Funnel", true);
myBooks.put("Rat: A Biology", false );
myBooks.put("TimeIn", true);
myBooks.put("3D Food Printing", false);
Library myLibrary = new Library();
myLibrary.getFinishedBooks(myBooks);
myLibrary.getUnfinishedBooks(myBooks);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment