Write a class named Book that has the following fields: ● author. The author field is a String object that holds the author's name. title. The title is a String object that holds the book's title. pages. The pages field is an int variable that holds the number of pages of the book. publisher. The publisher field is a String object that holds the publisher's title. phone. The phone field holds the publisher's phone number. What data type will you use for this field? Why?
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Program Approach:-
1. Create the class Book1
2. Data members
private String author1
private String title1
private int pages1
private String publisher1
private String phone1
3. Create parameterized constructor
4.Create the user-defined function String getAuthor().This function does not contain any parameter.
5. Create the user-defined function void setAuthor(String author). This function does contain one parameter.
6.Create the user-defined function String getTitle().This function does not contain any parameter.
7. Create the user-defined function void setTitle(String title). This function does contain one parameter.
8.Create the user-defined function String getPages().This function does not contain any parameter.
9. Create the user-defined function void setPages(String pages). This function does contain one parameter.
10.Create the user-defined function String getPublisher().This function does not contain any parameter.
11. Create the user-defined function void setPublisher(String publisher). This function does contain one parameter.
12.Create the user-defined function String getPhone().This function does not contain any parameter.
13. Create the user-defined function void setPhone(String phone). This function does contain one parameter.
14. Create the object of the class
15. Call the function
16. Display the output
Step by step
Solved in 3 steps with 1 images