Guest User

Untitled

a guest
Oct 13th, 2019
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ex73;
  2.  
  3. public class Book {
  4. private static int counter;
  5. private String title;
  6. private String author;
  7. private int id;
  8.  
  9. Book(String title, String author) {
  10. this.title = title;
  11. this.author = author;
  12. id = ++counter;
  13. }
  14.  
  15. @Override
  16. public String toString() {
  17. return String.format("Автор: %s%nНазвание: %s%nИндекс: %d%n", author, title, id);
  18. }
  19.  
  20. int getId() {
  21. return id;
  22. }
  23.  
  24. String getTitle() {
  25. return title;
  26. }
  27.  
  28. String getAuthor() {
  29. return author;
  30. }
  31.  
  32. static int getCounter() {
  33. return counter;
  34. }
  35. }
RAW Paste Data