Guest User

Untitled

a guest
Jun 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. class Book {
  2.  
  3. String bookTitle;
  4. String author;
  5. String isbn;
  6. int numOfCopies ;
  7.  
  8. public String getBookTitle() {
  9. return bookTitle;
  10. }
  11. public void setBookTitle(String bookTitle) {
  12. this.bookTitle = bookTitle;
  13. }
  14. public String getAuthor() {
  15. return author;
  16. }
  17. public void setAuthor(String author) {
  18. this.author = author;
  19. }
  20. public String getIsbn() {
  21. return isbn;
  22. }
  23. public void setIsbn(String isbn) {
  24. this.isbn = isbn;
  25. }
  26. public int getNumOfCopies() {
  27. return numOfCopies;
  28. }
  29. public void setNumOfCopies(int numOfCopies) {
  30. this.numOfCopies = numOfCopies;
  31. }
  32. public Book(String bookTitle, String author, String isbn, int numOfCopies) {
  33. super();
  34. this.bookTitle = bookTitle;
  35. this.author = author;
  36. this.isbn = isbn;
  37. this.numOfCopies = numOfCopies;
  38. }
  39. public Book() {
  40. super();
  41. // TODO Auto-generated constructor stub
  42. }
  43.  
  44.  
  45. void display(){
  46. System.out.println("bookTitle: "+ bookTitle+ " :");
  47. }
  48.  
  49.  
  50. }
  51. class BookStore {
  52. private Book[] books;
  53. private int size;
  54. private int index = 0;
  55.  
  56. public BookStore(int size) {
  57. this.size = size;
  58. books = new Book[size];
  59. }
  60.  
  61. void addBook(Book book) {
  62. if (index >= size) {
  63. System.out.println(" cant add the book");
  64. return ;
  65. }
  66. books[index++] = book;
  67. }
  68.  
  69. void sell(String bookTitle, int noOfCopies) {
  70.  
  71. }
  72.  
  73. void order(String isbn,String bookTitle, int nofOfCopies) {
  74.  
  75. }
  76.  
  77. void display() {
  78.  
  79. }
  80.  
  81. }
  82. public class Q2 {
  83.  
  84. public static void main(String[] args) {
  85. // it have 0 book
  86. Book[] books = new Book[10];
  87. int i = 0;
  88. for (Book book : books) {
  89. books[i] = new Book("book" + i, "author" + i, "isbn" + i, i + 10);
  90. i++;
  91. }
  92.  
  93. for (Book book : books){
  94. book.display();
  95. }
  96.  
  97.  
  98. }
  99. }
Add Comment
Please, Sign In to add comment