JAVA CODE For this program, you are tasked to create a class called Person which will have the following private properties: name - a string which holds the name of the person. age - an integer which holds the age of the person. gender - a character which holds the gender of the person. This could either be 'M' or 'F' Then, for this class, you need to create its getters and setters for all of its properties and its toString() method which simply returns its name, age, and gender in the format, name - age - gender. An example returned value from its toString() method is "Luce - 25 - M". Also implement its constructor with the following signature: public Person(String name, int age, char gender)   Additionally, you need to implement its isMinor() method which basically returns true if its age is lesser than 18 and false otherwise.   After creating the class Person, create the class Father which inherits from the Person class. This class will have a constructor with the following signature: public Father(String name, int age). You don't need to pass a gender value when creating a Father object because its gender will and should always be 'M'. This Father class will have 1 method, introduceWithStyle(int n) which accepts a positive integer variable n and will print the message "I am your father" n times with each line having an increasing number of spaces. For example, if n is 4 then the printed message would be: I am your father  I am your father   I am your father    I am your father   Finally, create another class Son which inherits from the Father class. This class should be set as final and should have two constructors: public Son(String name, int age) public Son(int age) - since no name is being passed here, set the name to "Unknown"   This will have its own introduceWithStyle(int n) method which prints the message "I am your son" in decreasing number of spaces. For example, if n is 4 then the printed message would be:    I am your son   I am your son  I am your son I am your son   For this program, you are also tasked to create the main(). In the main(), all you have to do are the following: Ask the user to input the details of the Father - its name and its age, and then instantiate an object of the Father class Ask the user to input the details of Son #1 - its name and its age as well, and then instantiate an object of the Son class Ask the user to input the details of Son #2 - only its age, and then instantiate another object of the Son class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

JAVA CODE

For this program, you are tasked to create a class called Person which will have the following private properties:

  • name - a string which holds the name of the person.
  • age - an integer which holds the age of the person.
  • gender - a character which holds the gender of the person. This could either be 'M' or 'F'

Then, for this class, you need to create its getters and setters for all of its properties and its toString() method which simply returns its name, age, and gender in the format, name - age - gender. An example returned value from its toString() method is "Luce - 25 - M". Also implement its constructor with the following signature: public Person(String name, int age, char gender)

 

Additionally, you need to implement its isMinor() method which basically returns true if its age is lesser than 18 and false otherwise.

 

After creating the class Person, create the class Father which inherits from the Person class. This class will have a constructor with the following signature: public Father(String name, int age). You don't need to pass a gender value when creating a Father object because its gender will and should always be 'M'. This Father class will have 1 method, introduceWithStyle(int n) which accepts a positive integer variable n and will print the message "I am your father" n times with each line having an increasing number of spaces. For example, if n is 4 then the printed message would be:

I am your father

 I am your father

  I am your father

   I am your father

 

Finally, create another class Son which inherits from the Father class. This class should be set as final and should have two constructors:

  • public Son(String name, int age)
  • public Son(int age) - since no name is being passed here, set the name to "Unknown"

 

This will have its own introduceWithStyle(int n) method which prints the message "I am your son" in decreasing number of spaces. For example, if n is 4 then the printed message would be:

   I am your son

  I am your son

 I am your son

I am your son

 

For this program, you are also tasked to create the main(). In the main(), all you have to do are the following:

  1. Ask the user to input the details of the Father - its name and its age, and then instantiate an object of the Father class
  2. Ask the user to input the details of Son #1 - its name and its age as well, and then instantiate an object of the Son class
  3. Ask the user to input the details of Son #2 - only its age, and then instantiate another object of the Son class

 

Here's a sample output of the user prompts so you will be guided with the correct formatting (spelling, spacing, and capitalizations):

FATHER

Enter name: Joselito Antonio

Enter age: 57

 

SON #1

Enter name: Andres Antonio

Enter age: 23

 

SON #2

Enter age: 5

Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY