0

I need to create a printing method. Once I call the method it will print the following code.

static Book1 a = new Book1("Miasha", "Secret Society", "Borrowed", 743281586);
    static Book1 b = new Book1("Omar Tyree", "What They Want", "On Shelf", 743228695);
    static Book1 c = new Book1("Eric Jerome Dickey", "The Other Women","On Shelf", 525947248)

Any help is needed. I just need to know where to start.

Thanks,

3
Contributors
3
Replies
10
Views
10 Years
Discussion Span
Last Post by cassyjack
0

I expect you have constractor for your book class something like this

public void Book1(String str1, String str2, String str3, int num)
{
   author = srt1;
   title = str2;
   status = str3;
   isbn = num;
}

some get methods

public String getAuthor() { return author;}
public String getTitle() { return title;}
public String getStatus() { return status;}
public int getIsbn() { return isbn;}

so you create method printMe for example

public void printMe( Book1 toPrint)
{
   System.out.println( toPrint.getAuthor() + " - " + toPrint.getTitle()
   + " - " + toPrint.getStatus() + " - " + toPrint.getIsbn() );
}

to call this method you just do this

toPrint(a);
   toPrint(b);
   toPrint(c);

Hope that is any help to you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.