Answered step by step
Verified Expert Solution
Link Copied!

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


image

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Where do we go from here?

Answered: 1 week ago