Results 1 to 6 of 6

Thread: Constructing a class from a different class

Threaded View

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Constructing a class from a different class

    I have two class: Library and Book.

    I want to construct a Book class by calling its class constructor from the Library class. How can i do this? My code doesn't work (Error: Cannot find symbol - Constructor Book() )
    Code:
    public void createBook()
    {
       Book newBook;
    	    
       newBook = new Book(); //Error line  
    }
    Here is the book constructor:
    Code:
    public Book(String BookAuthor, String BookTitle, String BookCost, String NumberOfPages, String BookGenre, int bookEnjoyability)
    {
       //Initialise variables
       this.BookAuthor = BookAuthor;
       this.BookTitle = BookTitle;
       this.BookCost = BookCost;
       this.NumberOfPages = NumberOfPages;
       this.BookGenre = BookGenre;
    		
       this.bookEnjoyability = bookEnjoyability;
    }
    Last edited by x-ice; Feb 25th, 2007 at 07:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width