|
Bill Teter email: william.teter@plattsburgh.edu |
|
|
Lab 2 (lab exam) You will create three classes according to the specifications given below. The classes are Book, Author, Publisher. I have written the test program that will demonstrate that the classes that you create are working properly. 1. Create a directory called lab2 2. Copy into that directory my Test program 3. Read the Test.java program and notice that it
creates an Author, a Publisher and a Book and then prints data about the author
and then about the book. You can run this program by changing to my
directory and executing Test.java. From the command line: Author Name: Sam Smith tel: (518) 223-3232 Book Title: Java 4. Class requirements: Author class should have a string field called name and a String field called tel. The Constuctor should have two String formal parameters, the author's name and the author's telephone number. Override the toString() method so that it returns the name and telephone number of an author. Provide an accessor method called getName() that returns the author's name. Publisher class should have just one String field called name with is the name of the publisher. The constructor for Publisher should have one formal String parameter, the name of the publisher. Provide an accessor method called getName() that provides the name of the publisher. Book class will have 4 fields: a String field called title, a Author field called author, an int field called pages, and a Publisher field called publisher. The constructor will have 4 formal paramters that specify the title, author, number of pages and publisher in that order. Override the toString() method so that the returned string contains: title, name of the author, number of pages and publisher name. (See output above.) |