Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. 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
Step: 1
The Java class for the given requirements public class Person public String name public String favor...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started