Create a class called author is designed as follows three


Create a class called Author is designed as follows:

It contains:

• Three private instance variables: name (String), email (String), and gender (char of either ‘m' or ‘f');

• One constructor to initialize the name, email and gender with the given values;

And, a class called Book is designed as follows:

It contains:

• Four private instance variables: name (String), author (of the class Author you have just created), price (double), and qtyInStock (int). Assuming that each book is written by one author.

• One constructor which constructs an instance with the values given.

• Getters and setters: getName(), getAuthor(), getPrice(), setPrice(),getQtyInStock(), setQtyInStock(). Again there is no setter for name and author. Write the class Book (which uses the Author class written earlier).

Try:

1. Printing the book name, price and qtyInStock from a Book instance. (Hint:aBook.getName())

2. After obtaining the ‚Author? object, print the Author (name, email & gender) of the book.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a class called author is designed as follows three
Reference No:- TGS01516905

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)