Question: Create a class called Person. Person should have (instance variables should be private): private String name; private int age; 2 Constructors: Default constructor (no parameters)

Create a class called Person. Person should have (instance variables should be private): private String name; private int age; 2 Constructors: Default constructor (no parameters) Constructor which takes 2 parameters for name and age Methods: toString equals Appropriate set and get methods for setting and accessing the Person data. ---------------------------------------------------------- Create a class called Student which extends Person. Student has the private data: private String major; private double gpa; Similar to the Person class, add get and set methods. Add 2 constructors: default constructor Constructor which sets all necessary data in the Person and Student class (name, age, major and gpa) Methods: toString equals ------------------------------------------------------------ Create a Family class with the following: Constructor: Family (int size_of_family) Family contains an array of Person that is the size of "size_of_family". Family has a method called: void addPerson(Person p); The addPerson will call equals to make sure that the Person p hasn't already been added. If a duplicate is found, print out a message and continue without adding the duplicate person. void printOutFamily(); This routine calls all of the toString methods in the family. -------------------------------------------------------------- Run your Family with the following main routine: This output should be put into the JH6_worksheet.txt public static void main(String[] args) { Family f = new Family(8); Person fred= new Person("Fred Flintstone", 50); System.out.println("created " + fred); f.addPerson(fred); f.addPerson(fred); Student fredStudent = new Student("Fred Flintstone", 50, "Math", 3.1); System.out.println("created "+ fredStudent); f.addPerson(fredStudent); Person wilma = new Person("Wilma Flintstone", 48); f.addPerson(wilma); Student george= new Student("George", 21, "Politics", 3.1); System.out.println("created " + george); f.addPerson(george); george.setName("Georgie"); f.addPerson(new Student("George", 21, "Politics", 3.1)); f.addPerson(new Student("John", 18, "Geology", 2.9)); f.addPerson(new Student("Jane", 21, "Music", 3.2)); f.addPerson(new Student("Tarzan", 22, "Gymnastics", 4.0)); f.addPerson(new Student("Jim", 21, "Physics", 2.5)); f.addPerson(new Person("Robert", 18)); f.addPerson(new Person("Clemente", 32)); System.out.println("****** family listing: "); f.printOutFamily(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!