Implement a driver program to test out all constructors, JAVA Programming

Implement a class Book (Book.java). A book will have three instance variables: a title (a String, for example: "Big Java" or "The Hitchhiker's Guide to the Galaxy"), an author (a String, for example: "Cay Horstmann" or "Douglas Adams") and a price (a double, for example: 80.00 or 24.99). The class must include a:

  • Default constructor,
  • Parameterized constructor with three parameters (title, author, and price),
  • Accessor method to return the title,
  • Accessor method to return the author,
  • Accessor method to return the price,
  • Mutator method to set the title,
  • Mutator method to set the author,
  • Mutator method to set the price.

Implement a driver program (BookTest.java) to test out all the constructors and methods of your class as follows:

  • Create at least two Book objects, one using the default constructor and one using the parameterized constructor.
  • Use themutatormethods to set the title, author, and price for the Book object that was created using the default constructor.
  • Use theaccessormethods to get information that is then printed in sentences containing the author, title, and price of each book. An example sentence might be, "The Big Java book by CayHorstmanncosts $69.99." (Note that some of the information in this string comes from the values of your instance fields and the rest is text that you supply.

Document your Book class completely, using the appropriate Javadoc tags in your code. Include comments for the class, instance fields, and all methods. Use the JavaDocutility to generate an HTML documentation page for your Book class. In grading your project, we will generate the JavaDoc file from your source code file, so you do not have to turn it in.

You should have three files for this project:

    Book.java                     The Book class that has all the constructors and methods 
    BookTest.java               A driver program to test your Book class
    Book.html                     The documentation file generated from your Book class

Posted Date: 3/6/2013 4:29:56 AM | Location : United States







Related Discussions:- Implement a driver program to test out all constructors, Assignment Help, Ask Question on Implement a driver program to test out all constructors, Get Answer, Expert's Help, Implement a driver program to test out all constructors Discussions

Write discussion on Implement a driver program to test out all constructors
Your posts are moderated
Related Questions
Create a program Using Constructors? The further program uses the constructor to initialize a car rather than setting the areas directly. class CarTest7 { public static voi

You are a newly recruited programmer, working for an IT company. This company won a contract to develop a Customer Relationship Management System (CRM) for a major retailer. The CR

Explain the library java.lang.Math ? The Java class library is huge. We will not cover it all presently. In fact, the remaining eight classes will focus mostly on the class lib

Question A What are the difference between an interface and an abstract class? Question B Describe Exception Handling in JAVA Question C Describe the following with resp


What is virtual function? While derived class overrides the base class method by redefining the same function, after that if client wants to access redefined the method from der

You want the base class to represent only an interface for its derived classes. That means, you don't want anyone to actually instantiate an object of the parent class. You only


The Web container is used for managing the servlet's life cycle. The Web container produces an instance of the servlet and then the container invokes the init() function. At the co

Exercise 1) Lets start by query example in SPARQL: QUERY: What are the school's names that belong to the "local authority district" 00AA? NOTE 1: "Authority districts" divide UK i