diff --git a/report.md b/report.md new file mode 100644 index 0000000..2022ee5 --- /dev/null +++ b/report.md @@ -0,0 +1,44 @@ +# 3rd Assignment Report + +![](https://github.com/kianaghamsari/Second-Assignment/blob/develop/uni.png) + +## Kiana Ghamsari - 400222079 + + +# Introduction + +The purpose of the application is to manage a library using Java Object-Oriented Programming. + +The application includes 5 classes: +* Book +* Librarian +* Library +* Main +* User + +You can sign up or login if you already have an account as a ordinary user who can borrow a book, or as a librarian who manages the library. + + +# Structure + +* The `Library` class is the most important , and also, class `Main` runs the program by calling the method called `runMenu()`. +* The methods `newUserSignUp()` and `newLibrarianSignUp()` are created in `Main` to let new users sign up as either an ordinary user or a librarian. +* Users can borrow and return books from the library by `rentBook()` and `returnBook()` methods, respectively, defined in `User` class. +* The add, update, search, remove operations on all books and users objects are accessed only by librarians. These methods are defined in `Library` class. +* A Librarian can also borrow or return books due to it’s inheritance of `User` class. +* Librarian can, also, add or remove another librarian. + +# Bonus +In my implementation: + +* Usernames are unique +* A book cannot be borrowed twice +* The user cannot return the book that has not been borrowed +* All fields are private, and proper getters and setters are defined +* All functionalities are available from GUI + +# Conclusion: +* By this project, I've used basic concepts of object-oriented programming in an example. +* I, also, experienced working with access modifiers, public and private methods. +* I broke my code into individual classes that helped me increasing the readability of my code +* I didn't provide a back and exit command \ No newline at end of file diff --git a/src/main/java/Book.java b/src/main/java/Book.java index 7cff6f8..84bc60a 100644 --- a/src/main/java/Book.java +++ b/src/main/java/Book.java @@ -1,3 +1,52 @@ public class Book { //Book should contain name,author,year of publish and ISBN + private String name; + private String author; + private int yearOfPublish; + private String ISBN; + + public Book(String name, String author, int yearOfPublish, String ISBN) { + this.name = name; + this.author = author; + this.yearOfPublish = yearOfPublish; + this.ISBN = ISBN; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public int getYearOfPublish() { + return yearOfPublish; + } + + public void setYearOfPublish(int yearOfPublish) { + this.yearOfPublish = yearOfPublish; + } + + public String getISBN() { + return ISBN; + } + + public void setISBN(String ISBN) { + this.ISBN = ISBN; + } + + @Override + public String toString() { + return "Here is the information of " + this.getName() + "book:\nThe Book's Name: " + getName() + "\nThe Author's Name: " + getAuthor() + "\nThe Book's Year of Publish: " + getYearOfPublish() + "\nThe Book's ISBN: " + getISBN(); + } + } diff --git a/src/main/java/Librarian.java b/src/main/java/Librarian.java index 321ce3a..1126171 100644 --- a/src/main/java/Librarian.java +++ b/src/main/java/Librarian.java @@ -1,10 +1,17 @@ -public class Librarian { - /* - * The librarian should have a username and a password - * The librarian should be able to search users, librarians and books - * The librarian should be able to add\remove\update user add\remove\update_ - _ librarian and add\remove\update book - */ +public class Librarian extends User { + // /* + // * The librarian should have a username and a password + // * The librarian should be able to search users, librarians and books + // * The librarian should be able to add\remove\//update user add\remove\//update_ + // _ librarian and add\remove\//upd//ate book + // */ + public Librarian() { + super(); + } + + public Librarian(String username, String password) { + super(username, password); + } } diff --git a/src/main/java/Library.java b/src/main/java/Library.java index 6c34354..03df917 100644 --- a/src/main/java/Library.java +++ b/src/main/java/Library.java @@ -1,3 +1,7 @@ +import java.util.ArrayList; +import java.util.HashMap; +import javax.swing.*; + public class Library { /* * The library should have a list of books. @@ -6,79 +10,270 @@ public class Library { * The library should have a list of users and a list of librarians. */ + private ArrayList books; + private ArrayList users; + private ArrayList librarians; + private HashMap amountOfTheBook; + + + public Library() { + this.books = new ArrayList(); + this.librarians = new ArrayList(); + this.users = new ArrayList(); + this.amountOfTheBook = new HashMap(); + } + + public Library(Book books, Librarian librarians, User users) { + this.books = new ArrayList(); + this.librarians = new ArrayList(); + this.users = new ArrayList(); + this.amountOfTheBook = new HashMap(); + } + + + public ArrayList getBooks() { + return books; + } + + public void setBooks(ArrayList books) { + this.books = books; + } + + public ArrayList getUsers() { + return users; + } + + public void setUsers(ArrayList users) { + this.users = users; + } + + public ArrayList getLibrarians() { + return librarians; + } + + public void setLibrarians(ArrayList librarians) { + this.librarians = librarians; + } + + public HashMap getAmountOfTheBook() { + return amountOfTheBook; + } + + public void setAmountOfTheBook(HashMap amountOfTheBook) { + this.amountOfTheBook = amountOfTheBook; + } + //book related functions - public void addBook(){ - //TODO + public void addBook(Book book){ + if (doesBookExist(book.getISBN())) { + increaseBook(book.getISBN()); + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " added successfully!"); + } else { + books.add(book); + increaseBook(book.getISBN()); + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " added successfully!"); + } } - public void removeBook(){ - //TODO + public void removeBook(Book book){ + if (doesBookExist(book.getISBN())) { + books.remove(book); + decreaseBook(book.getISBN()); + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " has been removed."); + } else { + JOptionPane.showMessageDialog(null,"The book doesn't exist."); + } } - public void searchBook(){ - //TODO + public Book searchBook( String ISBN ){ + if (doesBookExist(ISBN)) { + for (Book book : books) { + if (book.getISBN().equals(ISBN)) { + JOptionPane.showMessageDialog(null,book); + return book; + } + } + } + JOptionPane.showMessageDialog(null,"The book doesn't exist."); + return null; } - public void updateBook(){ - //TODO + public void updateBook(String ISBN, String newName, String newAuthor, int newYearOfPublish){ + if ( doesBookExist(ISBN)){ + for (Book book : books) { + if (book.getISBN().equals(ISBN)) { + book.setName(newName); + book.setAuthor(newAuthor); + book.setYearOfPublish(newYearOfPublish); + } + } + JOptionPane.showMessageDialog(null,"Updated successfully!"); + } else { + JOptionPane.showMessageDialog(null,"The book doesn't exist."); + } } - public void doesBookExist(){ - //TODO + public boolean doesBookExist( String ISBN ){ + for (Book book : books) { + if (book.getISBN().equals(ISBN)) + return true; + } + return false; } - public void increaseBook(){ - //TODO + public void increaseBook(String ISBN){ + if (doesBookExist(ISBN)) { + amountOfTheBook.replace(ISBN, amountOfTheBook.get(ISBN) + 1); + } else { + amountOfTheBook.put(ISBN, 1); + } } - public void decreaseBook(){ - //TODO + public void decreaseBook(String ISBN){ + if (doesBookExist(ISBN)) { + amountOfTheBook.replace(ISBN, amountOfTheBook.get(ISBN) - 1); + } else { + JOptionPane.showMessageDialog(null,"The book doesn't exist."); + } } //user related functions - public void addUser(){ - //TODO + public void addUser(User user){ + if (doesUserExist(user.getUsername())) { + JOptionPane.showMessageDialog(null,"The user " + user.getUsername() + " already exists."); + } else { + users.add(user); + JOptionPane.showMessageDialog(null,"The user " + user.getUsername() + " added successfully!"); + } } - public void removeUser(){ - //TODO + public void removeUser(User user){ + if (doesUserExist(user.getUsername())) { + users.remove(user); + JOptionPane.showMessageDialog(null,"The user " + user.getUsername() + " has been removed."); + } else { + JOptionPane.showMessageDialog(null,"The username doesn't exist."); + } } - public void searchUser(){ - //TODO + public User searchUser(String username){ + if (doesUserExist(username)) { + for (User user : users) { + if (user.getUsername().equals(username)) { + JOptionPane.showMessageDialog(null,user); + return user; + } + } + } + JOptionPane.showMessageDialog(null,"The username doesn't exist."); + return null; } - public void updateUser(){ - //TODO + public void updateUser(String username, String newUsername, String newPassword){ + if ( doesUserExist(username) ) { + for (User user : users) { + if (user.getUsername().equals(username)) { + user.setUsername(newUsername); + user.setPassword(newPassword); + } + } + JOptionPane.showMessageDialog(null,"Updated successfully!"); + } else { + JOptionPane.showMessageDialog(null,"The username doesn't exist."); + } } - public void doesUserExist(){ - //TODO + public boolean doesUserExist(String username) { + for (User user : users) { + if (user.getUsername().equals(username)) + return true; + } + return false; } - //librarian related functions + public boolean areMatched(String first, String second) { + if (first.equals(second)) { + return true; + } + return false; + } - public void addLibrarian(){ - //TODO + public boolean userIsAuthenticated(String username, String password) { + if (doesUserExist(username)) { + for (User user : users) { + if (areMatched(user.getUsername(), username) && areMatched(user.getPassword(), password)) { + return true; + } + } + } + return false; } - public void removeLibrarian(){ - //TODO + //librarian related functions + + public void addLibrarian(Librarian librarian){ + if (doesLibrarianExist(librarian.getUsername())) { + JOptionPane.showMessageDialog(null,"The librarian " + librarian.getUsername() + " already exists."); + } else { + librarians.add(librarian); + JOptionPane.showMessageDialog(null,"The librarian " + librarian.getUsername() + " added successfully!"); + } } - public void searchLibrarian(){ - //TODO + public void removeLibrarian(Librarian librarian){ + if (doesLibrarianExist(librarian.getUsername())) { + librarians.remove(librarian); + JOptionPane.showMessageDialog(null,"The librarian " + librarian.getUsername() + " has been removed."); + } else { + JOptionPane.showMessageDialog(null,"The librarian doesn't exist."); + } } - public void updateLibrarian(){ - //TODO + public Librarian searchLibrarian(String username){ + if (doesLibrarianExist(username)) { + for (Librarian librarian : librarians) { + if (librarian.getUsername().equals(username)) { + JOptionPane.showMessageDialog(null,librarian); + return librarian; + } + } + } + JOptionPane.showMessageDialog(null,"The librarian doesn't exist."); + return null; } - public void doesLibrarianExist(){ - //TODO + public void updateLibrarian(String username, String newUsername, String newPassword){ + if ( doesLibrarianExist(username) ) { + for (Librarian librarian : librarians) { + if (librarian.getUsername().equals(username)) { + librarian.setUsername(newUsername); + librarian.setPassword(newPassword); + } + } + JOptionPane.showMessageDialog(null,"Updated successfully!"); + } else { + JOptionPane.showMessageDialog(null,"The librarian doesn't exist."); + } } + public boolean doesLibrarianExist(String username){ + for (Librarian librarian : librarians) { + if (librarian.getUsername().equals(username)) + return true; + } + return false; + } + public boolean librarianIsAuthenticated(String username, String password) { + if (doesLibrarianExist(username)) { + for (Librarian librarian : librarians) { + if (areMatched(librarian.getUsername(), username) && areMatched(librarian.getPassword(), password)) { + return true; + } + } + } + return false; + } } diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 9a347d3..b762361 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,6 +1,10 @@ -import java.util.Scanner; +import javax.swing.*; public class Main { + static Library library = new Library(); + static User user = new User(); + static Librarian librarian = new Librarian(); + /* * make a functional library app using oop * run the main program in Main.java and code the oop part in other classes @@ -9,10 +13,273 @@ public class Main { */ public static void main(String[] args) { - + runMenu(); } public static void runMenu(){ - //TODO: + while (true) { + String firstName = JOptionPane.showInputDialog(null,"Hello! Please enter your name."); + String firstChosenOption = JOptionPane.showInputDialog(null,"Welcome to the library, dear " + firstName + "!\n" + printChooseAnOption() + "\n" + displayFirstOption()); + switch (firstChosenOption) { + case "1": // Sign Up as a New User + String signUpChosenOption = JOptionPane.showInputDialog(null, printChooseAnOption() + "\n" + displaySignUpMenu()); + switch (signUpChosenOption) { + case "1": // Sign Up as a User + newUserSignUp(); + LoginAsAUser(); + break; + case "2": // Sign Up as a Librarian + newLibrarianSignUp(); + LoginAsALibrarian(); + break; + default: + runMenu(); + break; + } + break; + case "2": // Already Have an Account? Let's Login. + String loginChosenOption = JOptionPane.showInputDialog(null, printChooseAnOption() + "\n" + displayLoginMenu()); + switch (loginChosenOption) { + case "1": // Login as a user + LoginAsAUser(); + break; + case "2": // Login as a Librarian + LoginAsALibrarian(); + break; + default: + runMenu(); + break; + } + break; + default: + runMenu(); + break; + } + + } + } + + public static String printChooseAnOption() { + return "Please Choose One Option: "; + } + public static String displayFirstOption() { + return "1: Sign Up as a New User\n2: Already Have an Account? Let's Login."; + } + public static String displaySignUpMenu() { + return "1: Sign Up as a User\n2: Sign Up as a Librarian"; + } + public static String displayLoginMenu() { + return "1: Login as a User\n2: Login as a Librarian"; + } + public static String displayUserMenu() { + return "1: Borrow a Book\n2: Return a Book"; + } + public static String displayLibrarianMenu_Book() { + return displayUserMenu() + "\n3: Add a Book\n4: Remove a Book\n5: Search a Book\n6: Update a Book"; + } + public static String displayLibrarianMenu_User() { + return "1: Add a User\n2: Remove a User\n3: Search a User\n4: Update a User"; + } + public static String displayLibrarianMenu_Librarian() { + return "1: Add a Librarian\n2: Remove a Librarian\n3: Search a Librarian\n4: Update a Librarian"; + } + public static void newUserSignUp() { + String username = JOptionPane.showInputDialog(null, "Please enter a username: "); + String password = JOptionPane.showInputDialog(null, "Let's create a password: "); + User newUser =new User(username,password); + library.addUser(newUser); + } + + public static void newLibrarianSignUp() { + String username = JOptionPane.showInputDialog(null, "Please enter a username: "); + String password = JOptionPane.showInputDialog(null, "Let's create a password: "); + Librarian newUser =new Librarian(username,password); + library.addLibrarian(newUser); + } + + public static void LoginAsALibrarian() { + String username = JOptionPane.showInputDialog(null, "Please enter your username: "); + String password = JOptionPane.showInputDialog(null, "Please enter your password: "); + if (library.doesLibrarianExist(username)) { + if (library.librarianIsAuthenticated(username, password)) { + String librarianFirstMenuOption = JOptionPane.showInputDialog(null, "Welcome to your page dear " + username + "!\n" + printChooseAnOption() + "\n1: User Menu Options\n2: Librarian Menu Options\n3: Book Menu Options"); + switch (librarianFirstMenuOption) { + case "1": // User Menu Options + String librarianUserMenuOption = JOptionPane.showInputDialog(null, "*USER MENU OPTIONS*\n" + displayLibrarianMenu_User()); + switch (librarianUserMenuOption) { + case "1": // Add a User + newUserSignUp(); + break; + case "2": // Remove a User + String remove_searchUserViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to remove: "); + User removedUser = library.searchUser(remove_searchUserViaUsername); + library.removeUser(removedUser); + break; + case "3": // Search a User + String searchUserViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to search: "); + User searchedUser = library.searchUser(searchUserViaUsername); + JOptionPane.showMessageDialog(null, searchedUser); + break; + case "4": // Update a User + String update_searchUserViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to update: "); + User updatedUser = library.searchUser(update_searchUserViaUsername); + String newPassword = JOptionPane.showInputDialog(null, "Enter the new password: "); + library.updateUser(updatedUser.getUsername(), updatedUser.getPassword(), newPassword); + break; + default: + runMenu(); + break; + } + break; + case "2": // Librarian Menu Options + String librarianLibrarianMenuOption = JOptionPane.showInputDialog(null, "*LIBRARIAN MENU OPTIONS*\n" + displayLibrarianMenu_Librarian()); + switch (librarianLibrarianMenuOption) { + case "1": // Add a Librarian + newLibrarianSignUp(); + break; + case "2": // Remove a Librarian + String remove_searchLibrarianViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to remove: "); + User removedUser = library.searchUser(remove_searchLibrarianViaUsername); + library.removeUser(removedUser); + break; + case "3": // Search a Librarian + String searchLibrarianViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to search: "); + User searchedUser = library.searchUser(searchLibrarianViaUsername); + JOptionPane.showMessageDialog(null, searchedUser); + break; + case "4": // Update a Librarian + String update_searchLibrarianViaUsername = JOptionPane.showInputDialog(null, "Enter the username you want to update: "); + User updatedUser = library.searchUser(update_searchLibrarianViaUsername); + String newPassword = JOptionPane.showInputDialog(null, "Enter the new password: "); + library.updateUser(updatedUser.getUsername(), updatedUser.getPassword(), newPassword); + break; + default: + runMenu(); + break; + } + break; + case "3": // Book Menu Options + String librarianBookMenuOption = JOptionPane.showInputDialog(null, "*BOOK MENU OPTIONS*\n" + displayLibrarianMenu_Book()); + switch (librarianBookMenuOption) { + case "1": // Borrow a Book + String rent_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to rent: "); + Book rentBook = library.searchBook(rent_searchViaISBN); + librarian.rentBook(rentBook); + break; + case "2": // Return a Book + String return_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to return: "); + Book returnBook = library.searchBook(return_searchViaISBN); + librarian.returnBook(returnBook); + break; + case "3": // Add a Book + String add_bookName = JOptionPane.showInputDialog(null, "Enter the name of the book you want to add: "); + String add_bookAuthor = JOptionPane.showInputDialog(null, "Enter the author of the book you want to add: "); + String add_bookYearOfPublish = JOptionPane.showInputDialog(null, "Enter the publish year of the book you want to add: "); + String add_bookISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to add: "); + Book newBook = new Book(add_bookName, add_bookAuthor, Integer.parseInt(add_bookYearOfPublish), add_bookISBN); + library.addBook(newBook); + break; + case "4": // Remove a Book + String remove_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to remove: "); + Book removeBook = library.searchBook(remove_searchViaISBN); + library.removeBook(removeBook); + break; + case "5": // Search a Book + String searchBookViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to search: "); + Book searchedBook = library.searchBook(searchBookViaISBN); + JOptionPane.showMessageDialog(null, searchedBook); + break; + case "6": // Update a Book + String update_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to update: "); + String newBookName = JOptionPane.showInputDialog(null, "Enter the new name of the book you want to update: "); + String newBookAuthor = JOptionPane.showInputDialog(null, "Enter the new author of the book you want to update: "); + String newBookYearOfPublish = JOptionPane.showInputDialog(null, "Enter the new publish year of the book you want to update: "); + library.updateBook(update_searchViaISBN, newBookName, newBookAuthor, Integer.parseInt(newBookYearOfPublish)); + break; + default: + break; + } + break; + default: + runMenu(); + break; + } + + String librarianMenuOption = JOptionPane.showInputDialog(null, "Welcome to your page dear " + username + "!" + "\nWhat would you like to do?\n" + displayUserMenu()); + switch (librarianMenuOption) { + case "1": // Borrow a Book + String rent_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to rent: "); + Book rentBook = library.searchBook(rent_searchViaISBN); + user.rentBook(rentBook); + break; + case "2": // Return a Book + String return_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to return: "); + Book returnBook = library.searchBook(return_searchViaISBN); + user.returnBook(returnBook); + break; + default: + runMenu(); + break; + } + } else { + JOptionPane.showMessageDialog(null, "The username & password you entered do not match. Please try again: "); + LoginAsAUser(); + } + } else { + String wrongUsername = JOptionPane.showInputDialog(null, "This username doesn't exist. Do you want to Sign up as a new user?\n1: Yes, let's create a new account\n2: No, let's try again."); + switch (wrongUsername) { + case "1": + newUserSignUp(); + break; + case "2": + LoginAsAUser(); + break; + + default: + runMenu(); + break; + } + } + } + + public static void LoginAsAUser() { + String username = JOptionPane.showInputDialog(null, "Please enter your username: "); + String password = JOptionPane.showInputDialog(null, "Please enter your password: "); + if (library.doesUserExist(username)) { + if (library.userIsAuthenticated(username, password)) { + String userMenuOption = JOptionPane.showInputDialog(null, "Welcome to your page dear " + username + "!" + "\nWhat would you like to do?\n" + displayUserMenu()); + switch (userMenuOption) { + case "1": // Borrow a Book + String rent_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to rent: "); + Book rentBook = library.searchBook(rent_searchViaISBN); + user.rentBook(rentBook); + break; + case "2": // Return a Book + String return_searchViaISBN = JOptionPane.showInputDialog(null, "Enter the ISBN of the book you want to return: "); + Book returnBook = library.searchBook(return_searchViaISBN); + user.returnBook(returnBook); + break; + default: + runMenu(); + break; + } + } else { + JOptionPane.showMessageDialog(null, "The username & password you entered do not match. Please try again: "); + LoginAsAUser(); + } + } else { + String wrongUsername = JOptionPane.showInputDialog(null, "This username doesn't exist. Do you want to Sign up as a new user?\n1: Yes, let's create a new account\n2: No, let's try again."); + switch (wrongUsername) { + case "1": + newUserSignUp(); + break; + case "2": + LoginAsAUser(); + break; + default: + runMenu(); + break; + } + } } } diff --git a/src/main/java/User.java b/src/main/java/User.java index dbe4020..5c8b327 100644 --- a/src/main/java/User.java +++ b/src/main/java/User.java @@ -1,12 +1,79 @@ +import java.util.ArrayList; +import javax.swing.*; + public class User { //User should have a list of books //User should have a username and a password - public void rentBook(){ - //TODO + private String username; + private String password; + private ArrayList userBooks; + + + public User() { + + } + + public User(String username, String password) { + this.username = username; + this.password = password; + this.userBooks = new ArrayList(); + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public ArrayList getUserBooks() { + return userBooks; } - public void returnBook(){ - //TODO + public void setUserBooks(ArrayList userBooks) { + this.userBooks = userBooks; } + + public void rentBook(Book book){ + if (doesRentedBookExist(book.getISBN())){ + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " already exists."); + + } else { + userBooks.add(book); + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " added to your list successfully!"); + } + } + + public void returnBook(Book book){ + if (doesRentedBookExist(book.getISBN())) { + userBooks.remove(book); + JOptionPane.showMessageDialog(null,"The book " + book.getName() + " has been removed from your list."); + } else { + JOptionPane.showMessageDialog(null,"The book doesn't exist."); + } + } + + public boolean doesRentedBookExist(String ISBN) { + for (Book book : userBooks) { + if (book.getISBN().equals(ISBN)) + return true; + } + return false; + } + + @Override + public String toString() { + return "Hello, it's " + this.getUsername() + "!" + "\nThe Password: " + this.getPassword(); + } + }