Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Book {
- String bookTitle;
- String author;
- String isbn;
- int numOfCopies ;
- public String getBookTitle() {
- return bookTitle;
- }
- public void setBookTitle(String bookTitle) {
- this.bookTitle = bookTitle;
- }
- public String getAuthor() {
- return author;
- }
- public void setAuthor(String author) {
- this.author = author;
- }
- public String getIsbn() {
- return isbn;
- }
- public void setIsbn(String isbn) {
- this.isbn = isbn;
- }
- public int getNumOfCopies() {
- return numOfCopies;
- }
- public void setNumOfCopies(int numOfCopies) {
- this.numOfCopies = numOfCopies;
- }
- public Book(String bookTitle, String author, String isbn, int numOfCopies) {
- super();
- this.bookTitle = bookTitle;
- this.author = author;
- this.isbn = isbn;
- this.numOfCopies = numOfCopies;
- }
- public Book() {
- super();
- // TODO Auto-generated constructor stub
- }
- void display(){
- System.out.println("bookTitle: "+ bookTitle+ " :");
- }
- }
- class BookStore {
- private Book[] books;
- private int size;
- private int index = 0;
- public BookStore(int size) {
- this.size = size;
- books = new Book[size];
- }
- void addBook(Book book) {
- if (index >= size) {
- System.out.println(" cant add the book");
- return ;
- }
- books[index++] = book;
- }
- void sell(String bookTitle, int noOfCopies) {
- }
- void order(String isbn,String bookTitle, int nofOfCopies) {
- }
- void display() {
- }
- }
- public class Q2 {
- public static void main(String[] args) {
- // it have 0 book
- Book[] books = new Book[10];
- int i = 0;
- for (Book book : books) {
- books[i] = new Book("book" + i, "author" + i, "isbn" + i, i + 10);
- i++;
- }
- for (Book book : books){
- book.display();
- }
- }
- }
Add Comment
Please, Sign In to add comment