java - Boolean return statement (To make it not print true/false) -


My program runs and compiles, however, I did not get the desired output. It produces all the necessary information, but it also prints some things which I would not like to print very true / false statements along with patrons, authors and books:

  / * The right (current print statement) is true. True Name: Ken Lambert Title: Cider House Rule Author: John Irving Title: Perfect Hurricane Author: Sebastian Juger Title: The Illusion Author: Homer Title: Hamlet Author: William Shakespeare True Wrong Name: Ken Lambert Title: Perfect Storm Author: Sebastian Juger Title: Iliad Author: Homer Title: Hamlet Author: William Shakespeare (Current Print Statement) Name: Ken Lambert (Desired Print Statement) Title: Cider House Rule Writer: John Irving Title: Perfect Storm Author: Sebastian Juger Title: Iliad Author: Homer Title: Hamlet Author: William Shakespeare's Name: Ken Lambert Title: Perfect Storm Writer: Sebastian Juger Title: The Illusion Author: Homer Title: Hamlet Author: William Shakespeare * / Public Class Book {Private String Writer, Title; Public book (string t, string a) {author = a; Title = t; } Public string getAuthor () {return author; } Public string getTitle () {return title; } Public string toasting () {return "title:" + title + "\ n" + "Author:" + Author; }} Public Class Library Lists {Public Stable Zero Main (String [] Args) {Protector P = New Guardian ("Ken Lambert"); Book B1 = New Book ("Cedar House Rule", "John Irving"); Book B2 = New Book ("Perfect Storm", "Sebastian Junger"); Book B3 = New Book ("Iliad", "Homer"); Book B4 = New Book ("Hamlet", "William Shakespeare"); Println (p.borrowBook ​​(B1)); Println (p.borrowBook ​​(B2)); Println (p.borrowBook ​​(b3)); Println (p.borrowBook ​​(B4)); Println (P); System.out.println (p.returnbook ("Cedar House Rules")); System.out.println (p.hasBook ("Cedar House Rules")); System.out.println (p.hasBook ("Perfect Storm")); Println (P); }} Patron of the public class {Book B1, B2, B3, B4; The name of the private string; Public Protector (string nm) {name = nm; B1 = Faucet; B2 = Faucet; B3 = Faucet; B4 = null; } Public string getName (string nm) {if (name.equals (null) System.out.println ("You must give your name!"); Other name = nm; Name of return; } Public Boolean Borrowing Book (Book Book) {Boolean test = False; If (b1 == empty) {b1 = book; Test = true; } And if (b2 == empty) {b2 = book; Test = true; } And if (b3 == empty) {b3 = book; Test = true; } And if (B4 == empty) {b4 = book; Test = true; } Else {test = false; } Return exam; } Public Boolean hasBook (string title) {if (b1! = Null) if (b1.getTitle (.) Equals (title)) {back true; } And if (b2! = Null) if (b 2.getTitle (.) Equals (title)) {back true; } And if (b3! = Null) if (b 3.getTitle (.) Equals (title)) {return true; } And if (B4! = Null) if (b 4.getTitle (.) Equals (title)) {return true; }      return false; } Public Boolean Returnbook (String B) {if (b1.getTitle (). Equal (B)) {B1 = Faucet; Back true; } And if (b2.getTitle (.) Equals (b)) {b2 = zero; Back true; } And if (b 3.getTitle (.) Equals (b)) {b3 = null; Back true; } And if (b4.getTitle (.) Equals (b)) {b 4 = null; Back true; } Other {return false; }} Public string toString () {string str = "name:" + name; If (b1! = Null) str = str + "\ n" + b1; If (b2! = Null) str = str + "\ n" + b2; If (b3! = Null) str = str + "\ n" + b3; If (b4! = Null) str = str + "\ n" + b4; Return str; }} // class  

method public boolean credit book (book manual) gives a boolean as you print the return of the method, it prints ... boolean!

  System.out.println (p.borrowBook ​​(b1)); Println (p.borrowBook ​​(B2)); Println (p.borrowBook ​​(b3)); Println (p.borrowBook ​​(B4));  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -