CS1301 Lab 10

CS 1301 Lab 10

100 Points

Attendance is worth 10 points.

(90 points) Team Problem 1:
For this program you need to submit the source code (.java), including prolog.

Design two classes named Author and Book.

The class Author should have three private instance variables of type String called: name, email and gender. The constructor of the Author class should have three parameters of type String used to initialize the instance variables name, email and gender.

The Author class should have an accessor method called getName that returns the name instance variable.

The Book class should have two instance variables:

The Book class has to have a constructor with two parameters: one of type String (the book title) and one of type Author that holds the author information. The constructor initializes the instance variables.

The Book class has one method called toString(), return type String with no parameters. This method returns the concatenation of the title with the string ", by " and the author's name (using the author object's getName method).

Write a test program that creates an instance of an author object and a book written by that author. You will then use the System.out.println method to print the book object.

Below is one sample run of the program:

Sample run 1:
Maximum Ride: The Angel Experiment, by James Patterson

Sample run 2:
Introduction to Java Programming, by Y. Daniel Liang

To successfully complete this lab you should: