In Java langauge, please show the output of the program. Thank you

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

In Java langauge, please show the output of the program. Thank you

Create a Book object that has a book written by only one author. The class contains the following
members:
1. Four private data members: bookTitle (string), author (an instance of the class
Author), price (double), and stock (int, with default value of 0). The price shall be
positive and the stock shall be zero or positive. Take note that data member author is an
instance of the class Author, instead of a fundamental types (such as int, double,etc.).
2. The public getters and setters for the private data members. Take note that
getAuthor () returns an object (an instance of class Author).
Book Title : Java Book
: Marcus Laurence
: Male
: milaurence@neu.edu.ph
AUTHOR
3. A method print(), which prints
GENDER
E-MAIL
4. A method getAuthorName (), which returns the name of the author of this Book instance.
5. Use the BookTest for your reference:
Sample 1:
public class BookTest
public static void main(String[] args)
{
// Declare and construct an instance of Author
Author authori = new Author ("Marcus Laurence", "milaurence@neu.edu.ph", "Male");
author1.print();
Transcribed Image Text:Create a Book object that has a book written by only one author. The class contains the following members: 1. Four private data members: bookTitle (string), author (an instance of the class Author), price (double), and stock (int, with default value of 0). The price shall be positive and the stock shall be zero or positive. Take note that data member author is an instance of the class Author, instead of a fundamental types (such as int, double,etc.). 2. The public getters and setters for the private data members. Take note that getAuthor () returns an object (an instance of class Author). Book Title : Java Book : Marcus Laurence : Male : milaurence@neu.edu.ph AUTHOR 3. A method print(), which prints GENDER E-MAIL 4. A method getAuthorName (), which returns the name of the author of this Book instance. 5. Use the BookTest for your reference: Sample 1: public class BookTest public static void main(String[] args) { // Declare and construct an instance of Author Author authori = new Author ("Marcus Laurence", "milaurence@neu.edu.ph", "Male"); author1.print();
Author author1 = new Author("Marcus Laurence", "milaurence@neu.edu.ph", "Male");
author1.print();
// Declare and construct an instance of Book
Book bk1 = new Book("Java Book", author1, 1499, 10);
bk1.print();
author1.setEmail("cuscus@gmail.com");
author1.print();
bk1.print();
bk1.getAuthor ().setEmail("Laurence.marcus@gmail.com");
bk1.print();
AUTHOR
: Marcus Laurence
GENDER : Male
E-MAIL : milaurence@neu.edu.ph
Book Title : Java Book
AUTHOR : Marcus Laurence
GENDER : Male
E-MAIL : milaurence@neu.edu.ph
AUTHOR
: Marcus Laurence
: Male
: cuscus@gmail.com
GENDER
E-MAIL
Book Title : Java Book
AUTHOR
: Marcus Laurence
GENDER : Male
E-MAIL : cuscus@gmail.com
Book Title : Java Book
: Marcus Laurence
: Male
: Laurence.marcus@gmail.com
AUTHOR
GENDER
E-MAIL
Transcribed Image Text:Author author1 = new Author("Marcus Laurence", "milaurence@neu.edu.ph", "Male"); author1.print(); // Declare and construct an instance of Book Book bk1 = new Book("Java Book", author1, 1499, 10); bk1.print(); author1.setEmail("cuscus@gmail.com"); author1.print(); bk1.print(); bk1.getAuthor ().setEmail("Laurence.marcus@gmail.com"); bk1.print(); AUTHOR : Marcus Laurence GENDER : Male E-MAIL : milaurence@neu.edu.ph Book Title : Java Book AUTHOR : Marcus Laurence GENDER : Male E-MAIL : milaurence@neu.edu.ph AUTHOR : Marcus Laurence : Male : cuscus@gmail.com GENDER E-MAIL Book Title : Java Book AUTHOR : Marcus Laurence GENDER : Male E-MAIL : cuscus@gmail.com Book Title : Java Book : Marcus Laurence : Male : Laurence.marcus@gmail.com AUTHOR GENDER E-MAIL
Expert Solution
steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT