Guest User

Untitled

a guest
Oct 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package org.totalbeginner.tutorial;
  2.  
  3. public class Person {
  4. // Fields
  5. private String name; // This is the name of the person
  6. private int maximumBooks; // Max books person can check out
  7.  
  8. // constructors
  9. public Person() {
  10. name = "unknown name";
  11. maximumBooks = 3;
  12. }
  13.  
  14. // Methods
  15. public String getName() {
  16. return name;
  17. }
  18.  
  19. public void setName(String anyName) {
  20. name = anyName;
  21. }
  22. public int getMaximumBooks() {
  23. return maximumBooks;
  24.  
  25. }
  26. public void setMaximumBooks(int maximumBooks) {
  27. this.maximumBooks = maximumBooks;
  28. }
  29.  
  30. public String toString() {
  31. return this.getName() + " (" + this.getMaximumBooks() + " books)";
  32. }
  33.  
  34.  
  35.  
  36. }
Add Comment
Please, Sign In to add comment