Question

Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram)


Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) 


Author 

-name:String 

-email:String 

-gender:char 


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

+getName():String +getEmail):String 

+setEmail (email:String):void 

+getGender():char +tostring ):String . 


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 . 

Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and gender because these attributes cannot be changed. 


Now in your main method, create the following object from your class to test the Author constructor and call the public methods of the Author class. Override the toString ) to display name, age, and gender of the author and show that it works in your test case. Test case:

3 0
Add a comment Improve this question Transcribed image text
Answer #1
package question1;

public class Author {

    private String name;
    private String email;
    private char gender;

    public Author(String name, String email, char gender) {
        this.name = name;
        this.email = email;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

    public char getGender() {
        return gender;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", gender=" + gender;
    }

    public static void main(String[] args) {
        Author author = new Author("ronaldo", "ronaldoemail", 'm');
        System.out.println(author);
    }
}

Add a comment
Know the answer?
Add Answer to:
Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram)
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A class called Author is designed as shown in the class diagram. (JAVA)

    in javaA class called Author is designed as shown in the class diagram. Author name: String email: String gender: char +Author (name :String, email: String, gender char) +getName ():String +getEmail() String +setEmail (email: String) :void +getGender(): char +toString ():String 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; public Author (String name, String email, char gender) f......)  public getters/setters: getName(), getEmail setEmail and getGender(); (There are no setters for name and gender,...

  • In Java* Please implement a class called "MyPet". It is designed as shown in the following...

    In Java* Please implement a class called "MyPet". It is designed as shown in the following class diagram. Four private instance variables: name (of the type String), color (of the type String), gender (of the type char) and weight(of the type double). Three overloaded constructors: a default constructor with no argument a constructor which takes a string argument for name, and a constructor with take two strings, a char and a double for name, color, gender and weight respectively. public...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • I need help for part B and C 1) Create a new project in NetBeans called...

    I need help for part B and C 1) Create a new project in NetBeans called Lab6Inheritance. Add a new Java class to the project called Person. 2) The UML class diagram for Person is as follows: Person - name: String - id: int + Person( String name, int id) + getName(): String + getido: int + display(): void 3) Add fields to Person class. 4) Add the constructor and the getters to person class. 5) Add the display() method,...

  • Please do this in C++. Thank you in advance. Note that you have to carefully create...

    Please do this in C++. Thank you in advance. Note that you have to carefully create your class using the names and capitalization shown below. Put comments into your program, make sure you indent your program properly, and use good naming conventions. Create a class called entry. It should have two private data members of type std::string. One represents a name and the other represents an email address. Make sure you give them ,meaningful names. Create public getters and setters...

  • Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string...

    Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string +Contact()                     //default constructor sets all attribute strings to “unknown”; no other constructor +setName(string name) : void +setPhone(string pn) : void +setEmail(string em) : void +getName() : string +getPhone() : string +getEmail() : string +printContact() : void         //print out the name, phone numbers and email address Create New Project Name your project: CIS247_Lab7_YourLastName. For this exercise, you may use a header file or one file...

  • Create the class Book which has the following members: 1. private members: 1. title as String...

    Create the class Book which has the following members: 1. private members: 1. title as String 2. isbn as String 3. author as String 4. price as double 2. public members: 1. default constructor which initializes all data members to their default values. 2. non-default constructor which initializes all data members to parameters values. 3. toString which returns a representing String of the Book. 4. add all the setters and getters. Create the class EBook which is a subclass of...

  • Create a java class for an object called Student which contains the following private attributes: a...

    Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....

  • // Client application class and service class Create a NetBeans project named StudentClient following the instructions...

    // Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...

  • using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name...

    using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name : String # age: int # year: int + Club_Card (all parameters) + Setters & Getters + toString() : String + equals(x: Object): boolean [10 pts] Define the class Club_Card, which contains: 1. All arguments constructor which accepts all required arguments from the main and instantiate a Club_Card object. 2. Set & get method for each data attribute. 3. A toString() method which returns...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT