Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named Author that will represent information about potential authors of books. This class could be used in a publishing house company, a

Create a class named Author that will represent information about potential authors of books. This class could be used in a publishing house company, a bookstore, a library, etc. Use the UML class diagram for Author to help you create it. Author has three private data members, name, email, and gender. It includes accessor and modifier methods for each data member, a constructor, two methods to test for email and gender, and a toString method that can be used for printing the class data. Note that the toString method should make use of hasEmail() and hasGender() to adjust the output so those values are not printed if they are not set. Once you have created the class, you can test it with the AuthorTest.java program to check your class methods and data. Dont forget to add JavaDoc comments to your class and methods in Author.java. Descriptions may be brief for the time limits of the lab assignment.

Author

- name:String

- email:String

- gender:char

+ Author(name:String)

+ Author(name:String, email:String, gender:char)

+ getName():String

+ getEmail():String

+ getGender():char

+ setName(name:String):void

+ setEmail(email:String):void

+ setGender(gender:char):void

+ hasEmail():boolean

+ hasGender():boolean

+ toString():String

AuthorTest.java

/** * Unit 6 Lab: a class testing the Author class * * @author Tom Johnson * @since March 21, 2017 */

public class AuthorTest {

public static void main(String args[]) { //Create an Author object using the constructor with just a name Author me = new Author("Tom Johnson");

//Create an Author object using the constructor with a name, email, and gender Author you = new Author("Student", "student@uvn.edu", 'N');

//Print the authors System.out.println(me); System.out.println(you);

//Change the author names me.setName("Tim Boyd"); System.out.println("Changing the name: " + me);

//Adding an email and gender me.setEmail("tomjohnson@uvn.edu"); me.setGender('M'); System.out.println("With email and gender: " + me);

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions