Question: A: Creating a Class [10 marks] Write a Java class called Person. Each person will have a name (String), a favourite kind of pet


A: Creating a Class [10 marks] Write a Java class called Person.

A: Creating a Class [10 marks] Write a Java class called Person. Each person will have a name (String), a favourite kind of pet (String), and a list of the kind of every pet that this person has ever had (array of Strings). The pet list may contain the same kind of pet multiple times. Include a constructor that has three input parameters (for name, favourite kind of pet and pet list) and sets the initial state for the object. The constructor must make a new array for the list of pets and copy the data from the input array to this new one. Write a superHappy () method that returns true if more than 1/2 of all the pets that this person has had is their favourite kind of pet and returns false otherwise. Do not use information hiding/encapsulation for this class. Make everything accessible.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The Java class for the given requirements public class Person public String name public String favor... View full answer

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 Programming Questions!