Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?

image text in transcribed

image text in transcribed

package person;

import java.util.ArrayList;

public class library {

public static void main(String[] args) { ArrayList borrowers = new ArrayList(); ArrayList title = new ArrayList(); borrowers.add (new Person("Lady Gaga")); borrowers.add (new Person("Donald Trump")); borrowers.add (new Person("Albert Einstein")); borrowers.add (new Person("Indira Gandhi")); borrowers.add (new Person("Muhammed Ali")); borrowers.add (new Person("Diego Maradona"));

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

How would you describe your typical day at work?

Answered: 1 week ago