Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 3 . 4 : Assume you are asked to write a simple JAVA class Borrower representing a library user. Your program needs to manage

Q3.4: Assume you are asked to write a simple JAVA class Borrower representing a library user. Your program needs to manage the books borrowed from the university library.
a) Write a Java class to represent a Borrower. This class should contain instance variables to hold the following pieces of information. Be careful to choose the best types to hold this information.
[4 Marks]
The name of the Borrower (both first name and last name).
The index number of student library card.
The number of books that the student is currently borrowing.
The total number of books that have been borrowed by the student.
b) Write a constructor for your class. Your constructor will receive parameter data for first name, last name and library index number (which you can assume is in the form of a 3-digit string). You may assume that books borrowed from library are zeros.
[4 Marks]
c) Write a new class called Borrowers, which contains a single instance variable - an array of all the students in the class. In its constructor, please use the array with instances of your Borrower class to hold information on the following students:
[6 Marks]
\table[[First Name,Last Name,Card number],[Sidong,Wang,001],[Miao,Li,002],[Tian,Zhang,003]]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions