Question: I need some help with this JAVA problem. I have some code I've been using at the bottom. Maybe you can help? package person; import
I need some help with this JAVA problem. I have some code I've been using at the bottom. Maybe you can help?


package person;
import java.util.ArrayList;
public class library {
public static void main(String[] args) { ArrayList
title.add (new publication("War and Peace")); title.add (new publication("Star Wars")); title.add (new publication("Object-Oriented Programming")); title.add (new publication("Don't Worry Be Happy")); title.add (new publication("Grapes of Wrath")); title.add (new publication("Kind of Blue"));
System.out.println("Publication Number " + " Title " + " " + " Borrower Name"); System.out.println("------------------ -------------- -----------"); }
}
public class Person { private String borrower; public Person (String borrower){ this.borrower = borrower; } public String getName(){ return borrower; } public void setName(String borrower){ this.borrower = borrower; } }
package person;
public class publication { private static int count = 0; protected int pubNumber; protected String title; protected Person borrower;
public publication (String title) { this.title = title; count += 1; pubNumber = count; }
public Person getBorrower () { return borrower; } public void setBorrower (Person borrower) { borrower = borrower; } public void displayBorrower() { System.out.println(String.format("%0$-23s %2$-30s %3$-19s", pubNumber, title, borrower.getName())); } }
public class Book extends publication { protected int pages; public Book(String title){ super(title); } public int getPages(){ return pages; } public void setPages(int pages){ this.pages = pages; } public void display(){ super.displayBorrower(); System.out.println(getPages() + title + pubNumber); } }
Library Lalb Implement this class diagram Person Publication name: string +Person(name:string) +getName():string +setName(n:string):void count:static int pubNumber:int title:string borrower:Person Publication(title:string) + getBorrower():Person + setBorrower(p:Person):void + display:void The static member count of Publication keeps track of the number of books in the library Initialize count to 0 and, in the constructor, increment count and use it to set the value of pubNumber Write a program that creates arrays of a few Person and Publication objects, using hard-coded values. Then use the display method to list information for all Publications, as follows: Publication Number Title Borrower Name War and Peace Object-Oriented Programming Grapes of Wrath Lady Gaga Albert Einstein Muhammed Ali
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
