Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //wuu book pg 169
- public class LibraryCard
- {
- // declare the data members
- // create a Person who is an owner of this library card
- private Person owner;
- //number of books borrowed
- private int borrowCnt;
- //constructor
- public LibraryCard()
- {
- owner = null; // null --> qadt ma ghandiex ponter fil memorja fejn jezisti varible.
- borrowCnt = 0;
- }
- //numOfBooks checked out
- public void checkOut (int numOfBooks)
- {
- borrowCnt = borrowCnt + numOfBooks;
- }
- //return the number of books borrowed
- public int getNumberOfBooks()
- {
- return borrowCnt;
- }
- //return the name of owner
- public String getOwnersName()
- {
- return owner.getName();
- }
- //set owner name (card owner)
- public void setOwner (Person person)
- {
- owner = person;
- }
- //return a string representation of this card
- public String toSting()
- {
- return ("Owner Name: " + owner.getName() + "\n" +
- "Books borrowed : " + borrowCnt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement