Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. //wuu book pg 169
  2.  
  3.  
  4.  
  5. public class LibraryCard
  6. {
  7. // declare the data members
  8. // create a Person who is an owner of this library card
  9.  
  10. private Person owner;
  11.  
  12. //number of books borrowed
  13. private int borrowCnt;
  14.  
  15. //constructor
  16. public LibraryCard()
  17. {
  18. owner = null; // null --> qadt ma ghandiex ponter fil memorja fejn jezisti varible.
  19. borrowCnt = 0;
  20. }
  21.  
  22. //numOfBooks checked out
  23. public void checkOut (int numOfBooks)
  24. {
  25. borrowCnt = borrowCnt + numOfBooks;
  26. }
  27.  
  28. //return the number of books borrowed
  29. public int getNumberOfBooks()
  30. {
  31. return borrowCnt;
  32. }
  33.  
  34. //return the name of owner
  35. public String getOwnersName()
  36. {
  37. return owner.getName();
  38. }
  39.  
  40. //set owner name (card owner)
  41. public void setOwner (Person person)
  42. {
  43. owner = person;
  44. }
  45.  
  46. //return a string representation of this card
  47. public String toSting()
  48. {
  49. return ("Owner Name: " + owner.getName() + "\n" +
  50. "Books borrowed : " + borrowCnt);
  51. }
  52.  
  53.  
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement