In Java Develop a class definition for a Person Then develop

In Java:

Develop a class definition for a Person. Then develop a class definition for a Military Person that
inherits the properties of the Person, and a Navy Sailor that inherits the properties of a Military Person.   Finally, create two classes; an Officer and an Enlisted that each can inherit the properties of a Navy Sailor. At each level, include the following class variables:
Person: FirstName, MiddleInitial, LastName, Gender Military Person: Active Duty or Reserve Navy Sailor: Base where stationed, Surface Ship or Submarine, Date Commissioned, Rank
Include a toString() method in each class that will print out what type of class it is. Include methods read each of the class variables (i.e., getRank()) and methods to change the value of each class variable. Finally, develop methods so that all of the information in an object can be printed out. Write a short main() program to test it out.
Important Note: Be sure to incorporate the principles of encapsulation (Chapter 8 of Database Concepts Book Seventh Edition) in your definitions.

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

OUTPUT:

Person{FirstName=\'person\', MiddleInitial=\' \', LastName=\'one\', Gender=\'male\'}
Person{FirstName=\'person\', MiddleInitial=\' \', LastName=\'two\', Gender=\'male\'}
NavySailor{Base=\'StationOne\', ShipType=\'Submarine\', CommissionedDate=\'12-07-2016\', Rank=\'captain\'} Person{FirstName=\'person\', MiddleInitial=\' \', LastName=\'three\', Gender=\'male\'}

In Java: Develop a class definition for a Person. Then develop a class definition for a Military Person that inherits the properties of the Person, and a Navy S

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site